Search code examples
azure-resource-managerazure-rm-template

How do one add delay to deployment of ARM template resource?


I deploy 2 resources which one depends on another one but it seems to be a delay between first resource becoming fully operational and second resource being implemented. Code is below. First resource being deployed is DNS resource pointing to APP service and second resource is adding custom hostname binding to App Service. Issue is that there is seems to be a delay in up to 30 seconds between app service being able to validate DNS record being available to verify record. Is it possible somehow to add small delay between resources deployments since just using dependsOn is not sufficient in this case

{
         "apiVersion": "2020-09-01",
         "name": "[concat(parameters('webAppName'), '-mysite','/mysite.', variables('dnsZoneName'))]",
         "type": "Microsoft.Web/sites/hostNameBindings",
         "location": "[variables('location')]",
         "dependsOn": [
            "[resourceId('Microsoft.Network/dnszones/CNAME', variables('dnsZoneName'), 'mysite')]"
         ],
         "properties": {
            "domainId": null,
            "siteName": "[concat(parameters('webAppName'), '-mysite')]",
            "customHostNameDnsRecordType": "CName",
            "hostNameType": "Verified"
         }
      },
      {
         "type": "Microsoft.Network/dnszones/CNAME",
         "apiVersion": "2018-05-01",
         "dependsOn": [
            "[concat(parameters('webAppName'), '-mysite')]"
         ],
         "name": "[concat(variables('dnsZoneName'), '/mysite')]",
         "properties": {
            "TTL": 3600,
            "CNAMERecord": {
               "cname": "[reference(concat(parameters('webAppName'), '-mysite'), '2016-03-01', 'Full').properties.defaultHostName]"
            },
            "targetResource": {}
         }
      },

Solution

  • No, its not possible to do directly, but you can use a couple of alternatives:

    1. Deploy a dummy resource between those, you can find a resource that doesn't cost anything
    2. Do some fancy stuff with nested templates, like calling an empty nested template 10 times in a row (in sequence, not in parallel)
    3. Use deploymentScript resource to just issue a sleep 30 command.