We are using Cloud Service configuration to store app settings. But we would like to secure few appsettings like User Credentials,database connection string etc. What is the recommended way to do that?
We are reading this configuration from both web and worker role. Hence using aspnet_regiis utility is not an option as this is not available in worker role since iis is not installed in worker role.
We also considered using Key vault, but we end up in the same situation of securing the key vault key.
Unfortunately, Azure cloud service does not support managed service indentities
By default, Microsoft-managed keys protect your data, and Azure Key Vault helps ensure that encryption keys are properly secured. Azure key management also includes server-side encryption that uses service-managed keys, customer-managed keys in Azure Key Vault, or customer-managed keys on customer-controlled hardware.
Use Azure Storage Service Encryption to automatically encrypt data at rest in Azure Storage. Encryption, decryption, and key management are totally transparent to users. Data can also be secured in transit by using client-side encryption with Azure Key Vault.
Azure virtual network enables Azure resources to securely communicate with each other, the internet, and on-premises networks.
Use network security groups to secure your Azure App Service Environment by blocking inbound and outbound traffic to resources in your virtual network, or to restrict access to apps in an App Service Environment.
We also considered using Key vault, but we end up in the same situation of securing the key vault key.
Problem Statement
Even though you can move out all sensitive information to Azure Key Vault, but to access the Azure Key Vault you need clientID and client Secret key (to establish the identity of your cloud service and Key Vault to know that who is accessing it).
This means your application's client secret key will be sitting in cloud service configuration, which is almost equivalent to all sensitive information sitting in cloud service configuration in the first place :).
Solution Approach
Managed Service Identity would have been the way to go to access Azure Key Vault and avoid keeping client Secret key in cloud service configuration.
In absence of managed service identities for classic cloud services, you can use Certificate Credentials for application authentication to help establish application identity and get access to key vault for reading keys, secrets etc.
Details and Sample Code
Sample Code is available here: Authenticating to Azure AD in daemon apps with certificates
Just the important code pieces
// Initialize the Certificate Credential to be used by ADAL.
X509Certificate2 cert = ReadCertificateFromStore(certName);
// Then create the certificate credential client assertion.
certCred = new ClientAssertionCertificate(clientId, cert);
// Acquire Auth token for talking to Azure KeyVault..
result = await authContext.AcquireTokenAsync(todoListResourceId, certCred);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With