DEV Community

Cover image for Provide Storage for a New Company App
Fredrick Chukwuma
Fredrick Chukwuma

Posted on

Provide Storage for a New Company App

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.
In this project, we will be doing these tasks as follows using Microsoft Azure:

  • 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 a time-based retention policy and an encryption scope.

Storage Account in Microsoft Azure

A Storage Account in Microsoft Azure is a secure, scalable, and highly available cloud storage container that provides access to Azure Storage services such as Blob Storage (object storage), File Shares, Queues, and Tables. It serves as the foundational resource that defines how data is stored, replicated (LRS, ZRS, GRS), encrypted, and accessed over HTTPS endpoints. For applications, a storage account enables durable data persistence, backup, logging, content hosting, and data exchange with controlled access via role-based access control (RBAC) and shared access signatures (SAS).
In essence, a Storage Account stores and protects your application’s data.

Managed Identity for an Application in Microsoft Azure

A Managed Identity in Azure is an automatically managed identity in Microsoft Entra ID that allows an application (e.g., Azure VM, App Service, Function App) to authenticate securely to Azure services without storing credentials in code or configuration. Azure handles credential rotation and lifecycle management. When assigned appropriate role-based access control (RBAC) roles (e.g., Storage Blob Data Contributor), the application can securely access resources like a Storage Account using Azure AD-based authentication, eliminating the need for connection strings or secrets.
In essence, a Managed Identity secures how your application authenticates to access that data.

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.

storrage accounts

  • Select + Create.

create

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

app rg

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

account name

  • Move to the Encryption tab.

encryption tab

  • Check the box for Enable infrastructure encryption.

infrastructure encryption

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

warning statement

  • Select Review + Create.

review

  • Wait for the resource to deploy.

deploy

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

  • Search for and select Managed identities.

managed identities

  • Select Create.

create managed identities

  • Select your resource group.

odoniappRG

  • Give your managed identity a name.

odoni staffs

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

  • Search for and select your storage account.

storage accounts select

  • Select the Access Control (IAM) blade.

access control

  • Select Add role assignment.

add role assignment

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

job functioin

  • On the Members page, select Managed identity.

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. select members
  • Click Select and then Review + assign the role.

review

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

review and assign

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

resource

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

access control

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

add role

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

access

  • Select Select members.

select members

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

select user account

  • Click Select and then Review + assign.

review

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

create

  • You are now ready to continue with the lab.

2. Create a key vault to store the access keys.
A Key Vault in Microsoft Azure is a secure, cloud-based service used to store and manage sensitive information such as: Secrets (passwords, connection strings, API keys), Cryptographic keys (RSA, ECC keys used for encryption/signing), Certificates (SSL/TLS certificates).
Azure Key Vault protects your application's secrets and cryptographic materials while controlling exactly who or what can access them.

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

key vaults

  • Select Create.

create

  • Select your resource group.

select rg

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

key vault name

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

access configuration

  • Select Review + create.

review

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

Icreate

  • After the deployment, select Go to resource.

go to resource

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

soft delete

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

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

key

  • Select Generate/Import and Name the key.

generate key

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

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

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

resource group

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

access control

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

role assignment

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

job function

  • On the Members page, select Managed identity.

managed identity

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

user assigned

  • Select your managed identity.

managed identity

  • Click Select and then Review + assign.

review

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

  • Return to your storage account.

storage

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

encryption

  • Select Customer-managed keys.

customer managed keys

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

key select

  • Select to confirm your choices.
  • Ensure the Identity type is User-assigned.

identity type

  • Select an identity.
  • Select your managed identity, then select Add.

add managed identity

  • Save your changes.

save

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

Configure a 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.

storage account

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

containers

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

create container

  • Upload a file to the container.

upload file

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

access policy

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

retention period

  • Be sure to Save your changes.

save

  • Try to delete the file in the container.

try to delete

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

failed to delete

2. The developers require an encryption scope that enables 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.

add

  • Give your encryption scope a name.

encryption scope

  • The Encryption type is Microsoft-managed key.

encryption type

  • Set Infrastructure encryption to Enable.

enable

  • Create the encryption scope.

create

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

new container

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

container name

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

create

Conclusion

In Microsoft Azure, a secure storage architecture for an application is achieved by combining Storage Account, Managed Identity, Key Vault, and Encryption Scope into a cohesive security model.

The Storage Account delivers scalable and durable data persistence. Managed Identity provides passwordless, Azure AD–based authentication, eliminating hardcoded credentials. Key Vault centrally protects and manages cryptographic keys and secrets with strict access control and auditing. Encryption Scope enables granular control of data-at-rest encryption, allowing specific containers or blobs to be encrypted with designated customer-managed keys (CMKs).

Together, these components enforce least-privilege access, strong cryptographic governance, and compartmentalized encryption boundaries, resulting in a compliant, enterprise-grade storage solution.

Top comments (2)

Collapse
 
harsh2644 profile image
Harsh

Great breakdown! Love how you've covered both security and compliance — especially the part about customer-managed keys and retention policies. Azure newbies like me find this super helpful!

Collapse
 
fredrick_chukwuma_13220c9 profile image
Fredrick Chukwuma

Oh thanks
I’m glad you find the article helpful 🫶🏽