Introduction
Modern cloud applications require secure ways to access storage resources without exposing sensitive credentials or access keys.
In Microsoft Azure, developers can secure storage accounts using Managed Identities, Role-Based Access Control (RBAC), and immutable storage policies.
In this guide, we’ll configure secure Azure Storage access while exploring identity-based authentication and protected immutable storage.
By the end of this tutorial, you’ll know how to:
- Configure secure Azure Storage access
- Use Managed Identities for authentication
- Implement Azure RBAC
- Configure immutable blob storage policies
Let’s build a more secure Azure storage environment.
What are Managed Identities and RBAC?
Managed Identities allow Azure resources to securely authenticate to other Azure services without storing credentials inside application code.
Azure Role-Based Access Control (RBAC) helps manage who or what can access Azure resources and what actions they can perform.
Together, these features help organizations:
- Eliminate hardcoded credentials
- Control access permissions centrally
- Improve cloud security
- Support least-privilege access principles
Immutable storage adds another layer of protection by preventing critical data from being modified or deleted during a retention period.
Prerequisites
Before we begin, ensure you have:
- A Microsoft Azure account
- An active Azure subscription
- A stable internet connection
- Access to the Azure Portal
Now come with me, let’s build a secure Azure storage environment.
Create the storage account and managed identity
-
Provide a storage account for the web app.
- In the portal, search for and select 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.
- 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.
- Wait for the resource to deploy.
- In the portal, search for and select Storage accounts.
-
Provide a managed identity for the web app to use. Learn more about managed identities.
- Search for and select Managed identities.
- Select Create.
- Select your resource group.
- Give your managed identity a name.
- Select your resource group.
- Select Review and create, and then Create.
- Search for and select 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.
- Select the Access Control (IAM) blade.
- Select Add role assignment (center of the page).
- On the Job functions roles page, search for and select the Storage Blob Data Reader role.
- 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.
- Click Select and then Review + assign the role.
- Select Review + assign a second time to add the role assignment.
- Your storage account can now be accessed by a managed identity with the Storage Data Blob Reader permissions.
- Search for and select your storage account.
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.
- Select your resource group, and then the Access Control (IAM) blade.
- Select Add role assignment (center of the page).
- On the Job functions roles page, search for and select the Key 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.
- Click Select and then Review + assign.
- Select Review + assign a second time to add the role assignment.
- You are now ready to continue with the lab.
- In the portal, search for and select Resource groups.
-
Create a key vault to store the access keys.
- In the portal, search for and select Key vaults.
- Select Create.
- Select your resource group.
- Provide the name for the key vault. The name must be unique.
- Ensure on the Access configuration tab that Azure role-based access control (recommended) is selected.
- Select Review + create.
- Wait for the validation checks to complete and then select Create.
- After the deployment, select Go to resource.
- On the Overview blade ensure both Soft-delete and Purge protection are enabled.
- In the portal, search for and select Key vaults.
-
Create a customer-managed key in the key vault.
- In your key vault, in the Objects section, select the Keys blade.
- Select Generate/Import and Name the key.
- Take the defaults for the rest of the parameters, and Create the key.
- In your key vault, in the Objects section, select the Keys blade.
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.
- Select your resource group, and then the Access Control (IAM) blade.
- Select Add role assignment (center of the page).
- On the Job functions roles page, search for and select the Key Vault Crypto Service Encryption User role.
- 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.
- Select Review + assign a second time to add the role assignment.
- In the portal, search for and select Resource groups.
-
Configure the storage account to use the customer managed key in your key vault.
- Return to your the storage account.
- In the Security + networking section, select the Encryption blade.
- Select Customer-managed keys.
-
Select a key vault and key. Select your key vault and key.
-
Select to confirm your choices.
- Ensure the Identity type is User-assigned.
-
Select an identity.
- Select your managed identity then select Add.
-
Save your changes.
- If you receive an error that your identity does not have the correct permissions, wait a minute and try again.
- Return to your the storage account.
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.
- 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.
- Try to delete the file in the container.
- Verify you are notified failed to delete blobs due to policy.
- Navigate to your storage account.
-
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.
- Return to your storage account and create a new container.
- Give the New container, a Name.
- Notice in the Advanced section you can select the Encryption scope you created and apply it to all blobs in the container.
- Navigate back to your storage account.
Cleanup your resources
If you are working with your own subscription and have completed these labs, take a minute to delete the lab resources. This will ensure resources are freed up and cost is minimized. The easiest way to delete the lab resources is to delete the lab resource group.
- In the Azure portal, select the resource group, select Delete the resource group, Enter resource group name, and then click Delete.
- Using Azure PowerShell,
Remove-AzResourceGroup -Name resourceGroupName. - Using the CLI,
az group delete --name resourceGroupName.
Conclusion
Congratulations on successfully configuring secure Azure Storage access using Managed Identities, RBAC, and immutable storage policies.
In this lab, we explored how Azure security features can help organizations protect storage resources while simplifying authentication and access management.
Some key takeaways from this lab include:
- Managed Identities eliminate the need for hardcoded credentials
- Azure RBAC enables centralized access management
- Immutable storage helps protect critical data from modification or deletion
- Identity-based authentication improves cloud security posture
By completing this exercise, you have taken another important step in building practical Azure security and cloud administration skills.
See you in the next article.
Top comments (0)