Search code examples
azureazure-sql-databaseazure-rm-templateazure-cli2

How to stop a resource deployment in arm Azure template until first one is done?


I'm trying to deploy a SQL server and SQL data warehouse in arm template mode in Azure CLI. The issue is, the template fails because it's using a SQL server name to create a data warehouse. So, my question is how to stop the data warehouse deployment until the SQL server is deployed successfully?

Or is there any way to stop it until the SQL server is successfully deployed?


Solution

  • You would use the dependsOn property of a resource definition:

    {
      "type": "Microsoft.Compute/virtualMachineScaleSets",
      "name": "[variables('namingInfix')]",
      "location": "[variables('location')]",
      "apiVersion": "2016-03-30",
      "tags": {
        "displayName": "VMScaleSet"
      },
      "dependsOn": [
        "[variables('loadBalancerName')]",
        "[variables('virtualNetworkName')]",
        "storageLoop",
      ],
      ...
    }
    

    In the example above, the vm scale set does not get created until the load balancer, vnet and storage account are first created.

    Documentation on how to use it: https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-define-dependencies