Azure Storage automatically encrypts data at rest to protect it from unauthorized access. However, organizations that require greater control over encryption can use Customer-Managed Keys (CMKs) stored in Azure Key Vault.
In this article, we will learn how to encrypt an Azure Storage Account using Azure Key Vault and Managed Identity. We will explore how to create and configure encryption keys in Azure Key Vault, enable a managed identity for the Storage Account, and grant the necessary permissions to access the encryption keys.
By using Customer-Managed Keys and Managed Identity, you can maintain greater control over your encryption keys while avoiding the need to store credentials in your application. This approach helps improve security and simplifies encryption key management in Azure.
Required Azure Resources
To encrypt an Azure Storage Account using Azure Key Vault and Managed Identity, you need the following Azure resources:
-
Azure Storage Account
An Azure Storage Account stores data such as blobs, files, queues, and tables. Azure Storage encrypts data at rest by default using Microsoft-managed keys.
In this example, we will configure the Storage Account to use Customer-Managed Keys (CMKs) stored in Azure Key Vault, allowing us to control key creation, rotation, and access.
-
Azure Key Vault
Azure Key Vault is a cloud service that securely stores and manages sensitive information, including encryption keys, secrets, and certificates.
For this scenario, Key Vault stores the customer-managed encryption key used by the Storage Account. You can configure key permissions and manage the key lifecycle without storing the key directly in your application.
-
Managed Identity
Managed Identity provides an identity for an Azure resource, allowing it to authenticate to other Azure services without requiring you to manage credentials manually.
For this example, we will enable a managed identity for the Storage Account and authorize it to access the encryption key in Azure Key Vault. Azure Storage can then use this identity to access the key when performing encryption-related operations.
-
Azure Role-Based Access Control (RBAC)
Azure RBAC helps control which identities can access specific Azure resources and what actions they can perform.
You must grant the appropriate permissions to the Storage Account's managed identity so that Azure Storage can access the customer-managed key in Key Vault. For example, when using the Azure RBAC permission model, the Key Vault Crypto Service Encryption User role can provide the required cryptographic permissions.
How Customer-Managed Key (CMK) Flow Works
Customer-Managed Keys (CMKs) allow you to control the encryption keys used to protect data in an Azure Storage Account. These keys are stored in Azure Key Vault, while Azure Storage uses them to protect its data encryption keys.
Let's understand how the process works when Azure Storage is configured to use a customer-managed key with Managed Identity.
-
Create a Customer-Managed Key
First, create an Azure Key Vaolt and generate an encryption key inside it. This key is called a Customer-Managed Key (CMK) because you control its lifecycle, including rotation and access permissions.
-
Enable Managed Identity
Enable a system-assigned or supported user-assigned managed identity for the Azure Storage Account. This identity allows Azure Storage to authenticate to Azure Key Vaolt without requiring you to store credentials.
-
Grant Key Access Permissions
Grant the Storage Account's managed identity the required permissions to access and use the encryption key in Azure Key Vaolt. You can configure these permissions using Azure RBAC or the Key Vaolt access policy model, depending on your Key Vaolt configuration.
-
Configure the Storage Account
Configure the Storage Account to use the customer-managed key stored in Key Vaolt. During configuration, select the appropriate Key Vaolt and key, and specify the managed identity that Azure Storage shoold use to access it.
-
Data Encryption and Decryption
When data is stored in Azure Storage, the service encrypts it using data encryption keys. The customer-managed key in Key Vaolt protects these data encryption keys rather than directly encrypting every stored object.
When Azure Storage needs to access the customer-managed key, it uses its managed identity to authenticate to Key Vaolt and perform the required cryptographic operations.
-
Manage the Encryption Key
You can manage the customer-managed key throughout its lifecycle. For example, you can rotate the key, control access permissions, and monitor key usage.
However, disabling or deleting the key, or revoking the required permissions, can prevent Azure Storage from accessing the key and may make your data unavailable. Key availability and recovery procedures are therefore essential.
This approach improves control over encryption keys while reducing the need to manage credentials manually.
Let's summerize it. The customer-managed key flow separates data storage from encryption key management. Azure Storage stores and encrypts your data, Azure Key Vault protects and manages the customer-managed key, and Managed Identity provides secure authentication between the services.
Summary
Encrypting an Azure Storage Account using Azure Key Vault and Managed Identity provides an additional level of control over data security. By using Customer-Managed Keys (CMKs), you can manage encryption keys, control access permissions, and handle key rotation according to your security requirements. Managed Identity enables Azure Storage to access Key Vault securely without storing credentials.
By configuring these services correctly, you can strengthen your data protection strategy while maintaining control over the encryption key lifecycle. Always ensure that the required permissions are configured correctly and that key availability, backup, and recovery are properly managed to avoid disrupting access to your stored data.
Thanks
