DEV Community

Cover image for Storage Solutions for a New Company App: Scalable, Secure, and Efficient
Oluwatobiloba Akinbobola
Oluwatobiloba Akinbobola

Posted on

Storage Solutions for a New Company App: Scalable, Secure, and Efficient

Introduction

As the company designs and develops its new app, ensuring secure and efficient storage is a top priority. Developers are setting up a storage system that restricts access solely through keys and managed identities, ensuring data remains protected. By implementing role-based access control, they aim to grant precise permissions that align with each team member’s responsibilities. For testing, they are introducing protected, immutable storage to maintain data integrity and support a safe, controlled environment for app development and refinement.

Architecture diagram

Architecture diagram

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. Storage accounts
    • Select + Create. + 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. Encryption
    • Move to the Encryption tab.
    • Check the box for Enable infrastructure encryption. Encryption02
    • Notice the warning, This option cannot be changed after this storage account is created.
    • Select Review + Create. Create 01
    • Wait for the resource to deploy. Deploy resource
  2. Provide a managed identity for the web app to use.
    • Search for and select Managed identities. Managed identities
    • Select Create. create MI
    • Select your resource group.
    • Give your managed identity a name. Review and create
    • Select Review and create, and then Create. create MI

go to resource

  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.
    • Select the Access Control (IAM) blade.
    • Select Add role assignment (center of the page). storage account
    • On the Job functions roles page, search for and select the Storage Blob Data Reader role. 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.
    • Select the managed identity you created in the previous step. Managed identity
    • Click Select and then Review + assign the role. Select Review + assign a second time to add the role assignment. Review + assign MI
    • 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. RG
    • Select your resource group, and then the Access Control (IAM) blade.
    • Select Add role assignment (center of the page). Add role assignmentKV
    • 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 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. MembersKV
    • Select Review + assign a second time to add the role assignment. Review + assignKV
    • 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. Key vaults
    • Select Create. Create
    • Select your resource group.
    • Provide the name for the key vault. The name must be unique. Basic KV
    • Ensure on the Access configuration tab that Azure role-based access control (recommended) is selected.
    • Select Review + create. Review + create KV01
    • Wait for the validation checks to complete and then select Create. Create validation
    • 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 enable Purge protection enable Purge protection enabled
  3. 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. Generate/Import
    • Take the defaults for the rest of the parameters, and Create the key. create createKv

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. ResourceG
    • Select your resource group, and then the Access Control (IAM) blade.
    • Select Add role assignment (center of the page). Add role assignment02
    • On the Job functions roles page, search for and select the Key Vault Crypto Service Encryption User role. Key Vault Crypto Service
    • 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. Review + assign
    • Select Review + assign a second time to add the role assignment. Review + assign
  2. 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 a key vault and key
    • Select to confirm your choices. Select
    • Ensure the Identity type is User-assigned.
    • Select an identity.
    • Select your managed identity then select Add.
    • Save your changes. Save IT
    • If you receive an error that your identity does not have the correct permissions, wait a minute and try again. correct permissions

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.
    • In the Data storage section, select the Containers blade. Data storage
    • Create a container called hold. Take the defaults. Be sure to Create the container. hold container
    • Upload a file to the container. Upload
    • 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. Retention period
    • Try to delete the file in the container. delete
    • Verify you are notified failed to delete blobs due to policy. failed to delete blobs
  2. 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. Encryption scopes created ecryption
    • Return to your storage account and create a new container.
    • 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. Advanced

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 Azure PowerShell
  • Using the CLI, az group delete --name resourceGroupName.

Top comments (0)