ARM – How to get the access key from a storage account to use in AppSettings later in the template

azure-resource-managerazure-storage

I'm creating an Azure Resource Manager template that instantiates multiple resources, including an Azure storage account and an Azure App Service with a Web App.

I'd like to be able to capture the primary access key (or the full connection string, either way is fine) from the newly-created storage account, and use that as a value for one of the AppSettings for the Web App.

Is that possible?

Best Answer

Use the listkeys helper function.

"appSettings": [
    {
      "name": "STORAGE_KEY",
      "value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value]"
    }
]

This quickstart does something similar:

https://azure.microsoft.com/en-us/documentation/articles/cache-web-app-arm-with-redis-cache-provision/

Related Topic