Attach a VM in a resourceGroup to storage in another ResourceGroup using templates


  • Hi,

    I have json templates that I am using to deploy a VM in a resourceMangerGroup which I am trying to add storage that already exists. The error I get is

    dnsNameForPublicIP: vmpun0191
    New-AzureRmResourceGroupDeployment : 16:12:02 - Resource Microsoft.Storage/storageAccounts 'ABCStorage2' failed with message 'The storage account named abcstorage2 already exists under the subscription.'
    At C:\Users\AnitaK\myAzureResource\scripts\createCloud resource1.ps1:28 char:4
    +    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGro ...
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
        + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand 

    It does not create a VM. What we would like to do is to have a storage in separate resource group and then when creating a VM attach to that storage Group. This is to avoid storage being deleted if the vm is removed.

    ---Teplate snippet-------
        "resources": [
                "type": "Microsoft.Storage/storageAccounts",
                "name": "[parameters('storageName')]",
    "apiVersion": "2015-05-01-preview",
                "location": "[variables('location')]",
                "tags": {
                    "displayName": "StorageAccount"

    "properties": {
    "accountType": "Standard_LRS"

    Friday, October 30, 2015 4:43 PM


All replies