DEV Community

Cover image for How to Provide Storage for a New Company App
Kosisochukwu Ugochukwu
Kosisochukwu Ugochukwu

Posted on

How to Provide Storage for a New Company App

Introduction
Although launching a new app for your business is an exciting endeavor, its success depends on having the right storage to manage user data efficiently. Regardless of the size of the application, from a small startup to an enterprise level product, Microsoft Azure provides scalable, secure, and extremely dependable storage solutions.

I will walk you through on how to set up storage for your new business app on Microsoft Azure in this guide.
Instructions for the exercise
First, establish the storage account and managed identity.
Step 1: Create a storage account for the web application.

  • In the portal, look for and select Storage accounts.
    Storage accounts

  • Select + Create

Select + Create

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

Resource group

  • Provide a Storage account name. Ensure the name is unique and meets the naming requirements.
  • Move to the Encryption tab.

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.

Select Review + Create

  • Wait for the resource to deploy.

resource to deploy

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

  • Search for and select Managed identities.

Managed identities

  • Select Create.

Select Create

  • Select your resource group.

resource group

  • Give your managed identity a name.
  • Select Review and create, and then Create.

managed identity

Step 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 account

  • Select the Access Control (IAM) blade.
  • 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.
  • Then Select Next

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.

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.

Review + assign

  • Your storage account can now be accessed by a managed identity with the Storage Data Blob Reader permissions.

Next we Secure access to the storage account with a key vault and key
**
**Step 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 group

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

Select Add role assignment

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

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.

Review + assign

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

add the role assignment

  • You are now ready to continue with the lab.

Step 2: Create a key vault to store the access keys.

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

Key vaults

  • Select Create.

Select Create

  • Select your resource group.
  • Provide the name for the key vault. The name must be unique.

key vault

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

Access configuration

validation wait

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

Image description

  • After the deployment, select Go to resource.

deployment

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

Overview blade

Step 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 the key

created

Configure the storage account to use the customer managed key in the key vault

Step 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.
  • Select your resource group, and then the Access Control (IAM) blade.
  • Select Add role assignment (center of the page).

select Resource groups

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

select the Key Vault Crypto Service Encryption

  • 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 Next. Select and then Next
  • Select Review + assign a second time to add the role assignment.

second time to add the role assignment

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

Customer-managed keys

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

key vault and key

  • Select to confirm your choices. key vault and key
  • Ensure the Identity type is User-assigned.
  • Click on Select an identity.
  • Select your managed identity then select Add.
  • Save your changes.

Select an identity

  • 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.
**
**Step 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.
  • Create a container called hold. Take the defaults. Be sure to Create the container.

Containers

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

Immutable blob storage section

  • For the Policy type, select time-based retention.
  • Set the Retention period to 5 days.
  • Be sure to Save your changes.

Retention period to 5 days

Save your changes

  • Try to delete the file in the container.
  • Verify you are notified failed to delete blobs due to policy.

notified failed

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

Image description

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

Conclusion
With Azure Blob Storage configured and connected into your app, you are now ready to manage data storage for the new business app efficiently. Microsoft Azure's scalability guarantees that your storage expands alongside your app, and its strong security measures provide piece of mind.

Start small, monitor your storage requirements, then scale up as your program develops popularity. Happy building!

Top comments (0)