DEV Community

Cover image for Provide storage for a new company app
Adebayo Ebofin
Adebayo Ebofin

Posted on

Provide storage for a new company app

Introduction
Azure Storage is a cloud-based storage solution offered by Microsoft Azure. It provides a highly scalable, durable, and secure platform for storing and managing various types of data. Azure Storage offers several services, each designed to meet specific storage needs.

Here are steps to create azure storage for company new app:
NOTE: The company is designing and developing a new app. Developers need to ensure the storage is only accessed using keys and managed identities. The developers would like to use role-based access control. To help with testing, protected immutable storage is needed.
Skilling tasks
Create the storage account and managed identity.
Secure access to the storage account with a key vault and key.
Configure the storage account to use the customer managed key in the key vault
Configure an time-based retention policy and an encryption scope.

Create the storage account and managed identity

  1. Provide a storage account for the web app. a. In the portal, search for and select Storage accounts.

Image description
b. Select + Create.

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

Image description
d. Provide a Storage account name. Ensure the name is unique and meets the naming requirements.

Image description
e. Move to the Encryption tab.
f. Check the box for Enable infrastructure encryption.
g. Notice the warning, This option cannot be changed after this storage account is created.

Image description
h. Select Review + Create.
i. Wait for the resource to deploy.

Image description

  1. Provide a managed identity for the web app to use. a. Search for and select Managed identities.

Image description
b. Select Create.

Image description
c. Select your resource group.
d. Give your managed identity a name.
e. Select Review and create, and then Create.

Image description

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

a. Search for and select your storage account.

Image description
b. Select the Access Control (IAM) blade.
c. Select Add role assignment (center of the page).

Image description

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

Image description
e. On the Members page, select Managed
identity.

Image description
f. Select Select members, in the Managed identity drop-down select User-assigned managed identity.
g. Select the managed identity you created in the previous step.
h. Click Select and then Review + assign the role.

Image description

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

Image description

j. 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. a. In the portal, search for and select Resource groups.

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

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

Image description
e. On the Members page, select User, group, or service principal.
f. Select Select members.

Image description
g. Search for and select your user account. Your user account is shown in the top right of the portal.
h. Click Select and then Review + assign.

Image description

Image description

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

Image description
j. You are now ready to continue with the lab.

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

a. In the portal, search for and select Key vaults.
b. Select Create.

Image description
c. Select your resource group.

Image description
d. Provide the name for the key vault. The name must be unique.

Image description
e. Ensure on the Access configuration tab that Azure role-based access control (recommended) is selected.
f. Select Review + create.

Image description
g. Wait for the validation checks to complete and then select Create.

Image description
h. After the deployment, select Go to resource.

Image description
i. On the Overview blade ensure both Soft-delete and Purge protection are enabled.

Image description

Image description

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

a. In your key vault, in the Objects section, select the Keys blade.
Image description
b. Select Generate/Import and Name the key.
c. Take the defaults for the rest of the parameters, and Create the key.

Image description

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. a. In the portal, search for and select Resource groups. b. Select your resource group, and then the Access Control (IAM) blade. c. Select Add role assignment (center of the page).

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

Image description
e. On the Members page, select Managed identity.
f. Select Select members, in the Managed identity drop-down select User-assigned managed identity.

Image description
g. Select your managed identity.
h. Click Select and then Review + assign.
Image description

Image description

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

Image description

  1. Configure the storage account to use the customer managed key in your key vault. a. Return to your the storage account. b. In the Security + networking section, select the Encryption blade. c. Select Customer-managed keys.

Image description=
d. Select a key vault and key. Select your key vault and key.
e. Select to confirm your choices.

Image description
f. Ensure the Identity type is User-assigned.

Image description
g. Select an identity.

Image description
h. Select your managed identity then select Add.
i. Save your changes.

Image description
j. 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.

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

a. Navigate to your storage account.

Image description
b. In the Data storage section, select the Containers blade.
c. Create a container called hold. Take the defaults. Be sure to Create the container.

Image description
d. Upload a file to the container.

Image description
e. In the Settings section, select the Access policy blade.
f. In the Immutable blob storage section, select + Add policy.

Image description
g. For the Policy type, select time-based retention.
h. Set the Retention period to 5 days.
i. Be sure to Save your changes.

Image description
j. Try to delete the file in the container.
k. Verify you are notified failed to delete blobs due to policy.

Image description

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

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

Image description
h. Return to your storage account and create a new container.
i. Notice on the New container page, there is the Name and Public access level.
j. Notice in the Advanced section you can select the Encryption scope you created and apply it to all blobs in the container.

Image description

Top comments (0)