DEV Community

Cover image for Provide storage for a new company app
Isaiah Izibili
Isaiah Izibili

Posted on

Provide storage for a new company app

Create the storage account and managed identity

1. Provide a storage account for the web app.

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

select storage accounts

  • Select + Create.

Select and create

  • For Resource group select Create new. Give your resource group a name and select OK to save your changes.

Resource group name

  • Provide a Storage account name. Ensure the name is unique and meets the naming requirements.

Storage account name

  • Move to the Encryption tab.

Encryption tab

  • Check the box for Enable infrastructure encryption.

Enable infrastructure encryption

  • Notice the warning, This option cannot be changed after this storage account is created.

  • Select Review + Create.

Review and create

  • Wait for the resource to deploy.

Resource has been deployed

2.Provide a managed identity for the web app to use. Learn more about managed identities.

  • Search for and select Managed identities.

Select manage identities

  • Select Create.

Select Create

  • Select your resource group.

Select resource group

  • Give your managed identity a name.

managed identity name

  • Select Review and create, and then Create.

Create

3. Assign the correct permissions to the managed identity. The identity only needs to read and list containers and blobs. Learn more about how to assign Azure roles.

  • Search for and select your storage account.

Select storage account

  • Select the Access Control (IAM) blade.

Select Access control blade

  • Select Add role assignment (center of the page).

Add role

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

Select storage blob Data Reader

  • On the Members page, select Managed identity.

  • Select Select members, in the Managed identity drop-down select User-assigned managed identity.

User-assigned managed identity

  • Select the managed identity you created in the previous step.

Select manage identity

  • Click Select and then Review + assign the role.

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

Create and assign role

  • 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

1. To create the key vault and key needed for this part of the lab, your user account must have Key Vault Administrator permissions. Learn more about how to provide access to Key Vault keys, certificates, and secrets with an Azure role-based access control

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

Select Resource group

  • Select your resource group, and then the Access Control (IAM) blade.

Select Access control blade

  • Select Add role assignment (center of the page).

Add role assignment

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

Key vault Administrator

  • On the Members page, select User, group, or service principal.

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.

Select Members

  • Click Select and then Review + assign.

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

Review and create

  • You are now ready to continue with the lab.

2.Create a key vault to store the access keys.

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

Select Key vaults

  • Select Create.

key vaults

  • Select your resource group.
  • Provide the name for the key vault. The name must be unique.

review and create

  • Ensure on the Access configuration tab that Azure role-based access control (recommended) is selected.

Azure role-based access control

  • Select Review + create.

Review and create

  • Wait for the validation checks to complete and then select Create.

Create

  • After the deployment, select Go to resource.

Select Resource

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

Soft-delete and Purge protection are enabled

Soft-delete n Purge protection are enabled

3. Create a customer-managed key in the key vault.

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

in the Objects section, select the Keys blade.

  • Select Generate/Import and Name the key.

Select Generate/Import and Name the key

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

Create

Key

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

1. Before you can complete the next steps, you must assign the Key Vault Crypto Service Encryption User role to the managed identity. Learn more about how to use a system-assigned managed identity to authorize access

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

Resource group

  • Select your resource group, and then the Access Control (IAM) blade.

navigate to access control

  • Select Add role assignment (center of the page).

add role assisgment

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

Key Vault Crypto Service Encryption User role

  • On the Members page, select Managed identity.

select Managed identity

  • Select Select members, in the Managed identity drop-down select User-assigned managed identity.

user assiggned managed identity

  • Select your managed identity.

Select your managed identity

  • Click Select and then Review + assign.

review and assign

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

Review and assign

2. Configure the storage account to use the customer managed key in your key vault. Learn more about customer managed keys on an existing storage account.

  • Return to your the storage account.

storage account

  • In the Security + networking section, select the Encryption blade.

select encryption

  • Select Customer-managed keys.

customer managed key

  • Select a key vault and key. Select your key vault and key.

select key vault and key

  • Select to confirm your choices.

Select to confirm

  • Ensure the Identity type is User-assigned.

user assigned

  • Select an identity.

Select an identity

  • Select your managed identity then select Add.

managed identity then select Add

  • Save your changes.

Save changes

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

user identity has been created

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

1.The developers require a storage container where files can’t be modified, even by the administrator. Learn more about blob immutable storage.

  • Navigate to your storage account.

storage account

  • In the Data storage section, select the Containers blade.

Select container blade

  • Create a container called hold. Take the defaults. Be sure to Create the container.

container named hold

  • Upload a file to the container.

upload a container

  • In the Settings section, select the Access policy blade.

select access pliocy blade

  • In the Immutable blob storage section, select + Add policy.

Add policy

  • For the Policy type, select time-based retention.

time based retention

  • Set the Retention period to 5 days.

  • Be sure to Save your changes.

Save your changes

  • Try to delete the file in the container.

delete file

  • Verify you are notified failed to delete blobs due to policy.

Verify you are notified failed

delete error

2. The developers require an encryption scope that enables infrastructure encryption. Learn more about infrastructure encryption.

  • Navigate back to your storage account.

storage account

  • In the Security + networking blade, select Encryption.

Encryption

  • In the Encryption scopes tab, select Add.

select Add

  • Give your encryption scope a name.

encryption name

  • The Encryption type is Microsoft-managed key.

  • Set Infrastructure encryption to Enable.

Infrastructure encryption to Enable

  • Create the encryption scope.

Create encryption scope

  • Return to your storage account and create a new container.

navigate to container

  • Notice on the New container page, there is the Name and Public access level.

public access level

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

Top comments (0)