Azure ARM Template dependsOn: Resource Not Defined in Template

DependsOn can only refer to resources in the same ARM template ?

From this official document about defining dependencies in Azure Resource Manager templates, we could find as follows:

Resource Manager evaluates the dependencies between resources, and deploys them in their dependent order. When resources are not dependent on each other, Resource Manager deploys them in parallel. You only need to define dependencies for resources that are deployed in the same template.

Based on my test, I could reproduce this issue. You need to add the Storage resource within your template as follows:

{
    "name": "[parameters('storageAccounts_simscitestrg6892_name')]",
    "type": "Microsoft.Storage/storageAccounts",
    "location": "[resourceGroup().location]",
    "apiVersion": "2015-06-15",
    "dependsOn": [],
    "tags": {
      "displayName": "StorageAccountResourceName"
    },
    "properties": {
      "accountType": "[parameters('StorageAccountType')]"
    }
}

For your VM resource, you could configure the osDisk under the "properties > storageProfile" section as follows:

"osDisk": {
  "name": "Your-VMOSDisk",
  "vhd": {
    "uri": "[concat('https://', parameters('storageAccounts_simscitestrg6892_name'), '.blob.core.windows.net/', variables('Your-VMStorageAccountContainerName'), '/', variables('Your-VMOSDiskName'), '.vhd')]"
  },
  "caching": "ReadWrite",
  "createOption": "FromImage"
}

The storage resource would be created under the same location as your VM, if not exists.


No, this makes no sense, the dependsOn property is meant to track dependencies inside the ARM template, so it can provision resources in specific order. If a resource is there, there's no sense to track it. It's already there. You just reference it when you use it.