The storage account already exists error when redeploying an ARM template

Update 06 Jul 2016

Seems this is resolved on the latest Storage Resource Provider API 2016-01-01. The schema documented at https://azure.microsoft.com/en-us/documentation/articles/resource-manager-template-storage/ is for 2015-06-15, and that version didn’t support PUT operations. The new 2016-01-01 schema can be found at:

So this new template now works as expected and tags and other settings can be changed:

{

    “$schema”: “https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#”,

    “contentVersion”: “1.0.0.0”,

    “resources”: [

      {

        “name”: “dnntest20160705”,

        “type”: “Microsoft.Storage/storageAccounts”,

        “location”: “[resourceGroup().location]”,

        “apiVersion”: “2016-01-01”,

        “dependsOn”: [ ],

        “tags”: {

          “displayName”: “MyStorageAccount”

        },

        “sku”: {

          “name”: “Standard_LRS”

        },

        “kind”: “Storage”

      }

    ]

}

 

Notes:

  • Ensure you install the latest Azure PowerShell and SDKs or the latest 2016-01-01 version won’t be recognized
  • With the latest Azure SDK 2.9.1 available, I have syntax errors on the template, seems the schema was not included in the latest release. While you have syntax errors, you can deploy from Visual Studio with no problems. I suppose this will be fixed on the next Azure SDK release.

Thanks to Tom FitzMacken for the indications.

_____________________________________________________________________________

Original issue description

Seems that when deploying an storage account using an ARM template like the one below:

{

    “$schema”: “https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#”,

    “contentVersion”: “1.0.0.0”,

    “resources”: [

      {

        “name”: “dnntest20160705”,

        “type”: “Microsoft.Storage/storageAccounts”,

        “location”: “[resourceGroup().location]”,

        “apiVersion”: “2015-06-15”,

        “dependsOn”: [ ],

        “tags”: {

          “displayName”: “MyStorageAccount”

        },

        “properties”: {

          “accountType”: “Standard_LRS”

        }

      }

    ]

}

 

If you go and change the “displayName” tag value for something else or try to add a new tag, when you deploy the update I get the following deployment exception:

22:44:07 – [ERROR] New-AzureRmResourceGroupDeployment : 22:44:07 – Resource

22:44:07 – [ERROR] Microsoft.Storage/storageAccounts ‘dnntest20160705’ failed with message ‘{

22:44:07 – [ERROR]   “error”: {

22:44:07 – [ERROR]     “code”: “StorageAccountAlreadyExists”,

22:44:07 – [ERROR]     “message”: “The storage account named dnntest20160705 already exists under

22:44:07 – [ERROR] the subscription.”

22:44:07 – [ERROR]   }

22:44:07 – [ERROR] }’

22:44:07 – [ERROR] At D:\temp\azureresourcegroup2\Scripts\Deploy-AzureResourceGroup.ps1:98 char:1

Workaround

Change the tag value through the portal/PowerShell, so new deployment updates work.

 

This sounds like a bug, that will probably be resolved in a future release.

davidjrh

David Rodriguez, is a happy Spanish guy living and working in Tenerife (Canary Islands, Spain) where he was born. He is one of the lucky ones who has the opportunity to work with cutting edge technologies at Intelequia as CTO. He has more than 20 years development background mostly based on Microsoft technologies, designing and architecting highly scalable systems like reservation systems for airlines companies. He has been working with Microsoft Azure since it was on CTP, migrating on-premise systems to the cloud, co-founding the .NET User Group TenerifeDev as well as the CSV company Intelequia Software Solutions. He is also the author of different DNN-Azure open source projects available on GitHub such as caching providers, analytics and Azure Active Directory.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *