DEV Community

Cover image for Storage for a new company app
Nwafor Somadina Emeka
Nwafor Somadina Emeka

Posted on

Storage for a new company app

We will be creating a storage for a new company application.

  1. Create a storage account.
  2. Configure a user-assigned managed identity.
  3. Configure a system-assigned managed identity.
  4. Configure a key vault with key.
  5. Configure a container with immutable storage.
  6. Configure an encryption scope.

storage plan

Create the storage account and managed identity

Provide a storage account for the web app.

  • In the portal, search for and select Storage accounts.

Storage accounts

  • Select + Create.
  • For Resource group select Create new. Give your resource group a name and select OK to save your changes.
  • Provide a Storage account name. Ensure the name is unique and meets the naming requirements.

Storage accounts

  • Move to the Encryption tab.
  • Check the box for Enable infrastructure encryption.
  • Notice the warning, This option cannot be changed after this storage account is created.
  • Select Review + Create.

Encryption tab

Encryption tab

  • Wait for the resource to deploy.

Encryption tab

Provide a managed identity for the web app to use.

  • Search for and select Managed identities.
  • Select Create.

 Managed identities

  • Select your resource group.
  • Give your managed identity a name.

 Managed identities

  • Select Review and create, and then Create.

 Managed identities

 Managed identities

Assign the correct permissions to the managed identity. The identity only needs to read and list containers and blobs.

  • Search for and select your storage account.

storage account

  • Select the Access Control (IAM) blade.
  • Select Add role assignment (center of the page).

Control (IAM) blade

  • On the Job functions roles page, search for and select the Storage Blob Data Reader role.

Control (IAM) blade

  • On the Members page, select Managed identity.
  • Select Select members, in the Managed identity drop-down select User- assigned managed identity.
  • Select the managed identity you created in the previous step.

managed identity

  • Click Select and then Review + assign the role.
  • Select Review + assign a second time to add the role assignment.

role assignment

  • Your storage account can now be accessed by a managed identity with the Storage Data Blob Reader permissions.

Secure access to the storage account with a key vault and key

To create the key vault and key needed for this part of the lab, your user account must have Key Vault Administrator permissions.

  • In the portal, search for and select Resource groups.

Resource groups

  • Select your resource group, and then the Access Control (IAM) blade.
  • Select Add role assignment (center of the page).

role assignment

  • On the Job functions roles page, search for and select the Key Vault Administrator role.

Vault Administrator role

  • On the Members page, select User, group, or service principal.
  • Select Select members.
  • Search for and select your user account. Your user account is shown in the top right of the portal.

 user account

  • Click Select and then Review + assign.
  • Select Review + assign a second time to add the role assignment.

 user account

  • You are now ready to continue with the lab.

Create a key vault to store the access keys.

  • In the portal, search for and select Key vaults.

Key vaults

  • Select Create.

Key vaults

  • Select your resource group.
  • Provide the name for the key vault. The name must be unique.
  • Select Review + create. Key vaults
  • Ensure on the Access configuration tab that Azure role-based access control (recommended) is selected.

Key vaults

Key vaults

  • Wait for the validation checks to complete and then select Create.
  • After the deployment, select Go to resource.

Key vaults

  • On the Overview blade ensure both Soft-delete and Purge protection are enabled.

Soft-delete and Purge protection

Soft-delete and Purge protection

Create a customer-managed key in the key vault.

  • In your key vault, in the Objects section, select the Keys blade.

key vault

  • Select Generate/Import and Name the key.

key vault

  • Take the defaults for the rest of the parameters, and Create the key.

key vault

Configure the storage account to use the customer managed key in the key vault

Before you can complete the next steps, you must assign the Key Vault Crypto Service Encryption User role to the managed identity.

  • In the portal, search for and select Resource groups.

key vault

  • Select your resource group, and then the Access Control (IAM) blade.
  • Select Add role assignment (center of the page).

key vault

  • On the Job functions roles page, search for and select the Key Vault Crypto Service Encryption User role.

Key Vault

  • On the Members page, select Managed identity.
  • Select Select members, in the Managed identity drop-down select User-assigned managed identity.
  • Select your managed identity.
  • Click Select and then Review + assign.

managed identity

  • Select Review + assign a second time to add the role assignment.

Configure the storage account to use the customer managed key in your key vault.

  • Return to your the storage account.

storage

  • In the Security + networking section, select the Encryption blade.
  • Select Customer-managed keys.

Encryption blade

  • Select a key vault and key. Select your key vault and key.
  • Select to confirm your choices.

networking section

  • Ensure the Identity type is User-assigned.
  • Select an identity.
  • Select your managed identity then select Add.
  • Save your changes.

identity

  • If you receive an error that your identity does not have the correct permissions, wait a minute and try again.

Configure an time-based retention policy and an encryption scope.

The developers require a storage container where files can’t be modified, even by the administrator.

  • Navigate to your storage account.
  • In the Data storage section, select the Containers blade.
  • Create a container called hold. Take the defaults. Be sure to Create the container.

Containers

  • Upload a file to the container.

Upload a file to the container

  • In the Settings section, select the Access policy blade.
  • In the Immutable blob storage section, select + Add policy.
  • For the Policy type, select time-based retention.
  • Set the Retention period to 5 days.
  • Be sure to Save your changes.

Immutable blob storage section

  • Try to delete the file in the container.
  • Verify you are notified failed to delete blobs due to policy.

delete blobs due to policy

The developers require an encryption scope that enables infrastructure encryption.

  • Navigate back to your storage account.
  • In the Security + networking blade, select Encryption.
  • In the Encryption scopes tab, select Add.
  • Give your encryption scope a name.
  • The Encryption type is Microsoft-managed key.
  • Set Infrastructure encryption to Enable.
  • Create the encryption scope.

enscope

  • Return to your storage account and create a new container.
  • Notice on the New container page, there is the Name and Public access level.

Public access

  • Notice in the Advanced section you can select the Encryption scope you created and apply it to all blobs in the container.

con1

Top comments (1)

Collapse
 
realcloudprojects profile image
SKILL.SCH

Nice