DEV Community

Cover image for Implementing Role-Based Access Control, Managed Identities, and Protected Immutable Storage
Yemi G
Yemi G

Posted on

Implementing Role-Based Access Control, Managed Identities, and Protected Immutable Storage

Create the storage account and managed identity

Provide a storage account for the web app.

In the portal, search for and select Storage accounts.

Image description

Select + Create.

Image description

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

Image description

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

Image description

Move to the Encryption tab.

Image description

Check the box for Enable infrastructure encryption.

Image description

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

Image description

Select Review + Create.

Wait for the resource to deploy.

Image description

2.** Provide a managed identity for the web app to use. **

Search for and select Managed identities.

Image description

Select Create.

Image description

Select your resource group.

Image description

Give your managed identity a name.

Image description

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. *

Search for and select your storage account.

Image description

Select the Access Control (IAM) blade.

Image description

Select Add role assignment (center of the page).

Image description

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

Image description

On the Members page, select Managed identity.

Image description

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

Image description

Image description

Select the managed identity you created in the previous step.

Image description

Click Select and then Review + assign the role.

Image description

Image description

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

Image description

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. *

In the portal, search for and select Resource groups.

Image description

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

Image description

Select Add role assignment (center of the page).

Image description

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

Image description

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

Image description

Select Select members.

Image description

Search for and select your user account. Your user account is shown in the top right of the portal.

Image description

Click Select and then Review + assign.

Image description

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

Image description

You are now ready to continue with the lab.

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

In the portal, search for and select Key vaults.

Image description

Select Create.

Image description

Select your resource group.

Image description

Provide the name for the key vault. The name must be unique.

Image description

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

Image description

Select Review + create.

Image description

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

Image description

After the deployment, select Go to resource.

Image description

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

Image description

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

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

Image description

Select Generate/Import and Name the key.

Image description

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.

In the portal, search for and select Resource groups.

Image description

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

Image description

Select Add role assignment (center of the page).

Image description

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

Image description

On the Members page, select Managed identity.

Image description

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

Image description

Select your managed identity.

Image description

Click Select and then Review + assign.

Image description

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. *

Return to your the storage account.

Image description

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

Image description

Select Customer-managed keys.

Image description

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

Image description

Select to confirm your choices.

Image description

Ensure the Identity type is User-assigned.

Image description

Select an identity.

Image description

Select your managed identity then select Add.

Image description

Save your changes.

Image description

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. *

Navigate to your storage account.

Image description

In the Data storage section, select the Containers blade.

Image description

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

Image description

Upload a file to the container.

Image description

In the Settings section, select the Access policy blade.

Image description

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

Image description

For the Policy type, select time-based retention.

Image description

Set the Retention period to 5 days.

Image description

Be sure to Save your changes.

Image description

Try to delete the file in the container.

Image description

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

  1. *The developers require an encryption scope that enables infrastructure encryption. *

Navigate back to your storage account.

Image description

In the Security + networking blade, select Encryption.

Image description

In the Encryption scopes tab, select Add.

Image description

Give your encryption scope a name.

Image description

The Encryption type is Microsoft-managed key.

Image description

Set Infrastructure encryption to Enable.

Image description

Create the encryption scope.

Image description

Return to your storage account and create a new container.

Image description

Notice on the New container page, there is the Name and 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.

Image description

Top comments (0)