StorageAccountAlreadyExists when running build step Azure Resource Group Deployment

1.9k views Asked by At

I'm trying to get my Build Definition to deploy all necessary resources (SQL Server, DB, Web-app and storage account) to azure, and update in case of a redeploy. I use Visual Studio Team Services VSTS / TFS. The build step "Azure Resource Group Deployment", fails with error:

"code": "StorageAccountAlreadyExists",
"message": "The storage account named mystorageaccountname already exists under the subscription."

Well, it is true that the storage account mystorageaccountname already exists, but that is usual the case when trying to implement continuous delivery and redeploy. I want to reuse the existing accounts.

For other resource, like a SQL server and SQL database the pre-existence of the resource is not an issue.

How can I do a Azure Resource Group Deployment that can be used over and over again?

5

There are 5 answers

1
Carlos B On

Check the name you have given to the storage account. It doesn't look like a valid one as it can't contain capital cases. Also, check that the existing storage you are referring to is not a 'classic' storage account (ASM) but an ARM.

More details here: https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-common-deployment-errors#storagenamenotunique

Regards, Carlos

1
Kieran On

two possible properties to check is

  1. Location
  2. tags

If you are trying to deploy with conflicting tags or location this error will show

0
Ian D On

Just had this same issue and it appeared to be that it was because the Resource Group that I wanted to create the server in was different to the resource group for the storage account.

1
Sam On

Just had this same issue and it turned out that the azure cli was creating a Premium_LRS storage account by default, but our template deployment specified a Standard_LRS storage account. It wouldn't reuse the storage account because of the different type, thus resulting in a naming conflict.

You might be having a similar issue?

0
Ajit Medhekar On

I had the same issue for redeployment of StorageAccount and KeyVault resources to same ResourceGroup. This was because of the Property - "tags".

  // "tags": {
  //   "displayName": "storageAccount1"
  // },

When I commented the code (then deleted the code from ARM template), it worked properly on redeployment scenario. As it's add tag to the resource so Azure deployment doesn't allow to redeploy the same resource with same tag value. Because of this redeployment fails.