0
votes

I currently have the storage account creation resource in my deployment template, but I need the Storage Access Key from the user. Is it possible to create Storage account & get Access Key?

This deployment is being done on the Azure Portal. I am currently using a custom template for deployment.

Update

I have a section in CreateUIDefinition file for asking the user to create a new Storage Account as below screenshot of preview

Now this Storage Account will be created once I move over to the "Review + Create" tab after validation and hit "Create".

But I need the Access Key of this Storage Account that the user is creating, so that I can store its value into a Key Vault Secret for later use.

Is this possible?

1
I do not understand what you want. With a custom template you mean an ARM template? What do you want to do with the Access Key?Peter Bons
You can definitely create a storage account by ARM template. You can also get the access key by ARM template and output the key. What do you mean by 'before user clicks create'?Stringfellow

1 Answers

0
votes

If you just want to make sure that your storage account has been created so that you can get its Access Key by:

[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value]

for your subsequence resources, you can just define its create order in your ARM template by dependsOn element. Details see here.

Update:

If you want to create a storage account first so that you can get its access key and save it to a key vault, I think you can do that.First of all you should define that your key vault is dependson Azure Storage account. So that Azure Storage account will be created first. Based on this doc, we can read access key from the first created Azure Storage account and save it into your Azure Key Vault. Of course in Microsoft.KeyVault/vaults/secrets you also need set :

"dependsOn": [
        "[resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName'))]"
      ]

to make sure that your key vault has been created.