Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

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": {}
         }
      },
question from:https://stackoverflow.com/questions/65930516/how-do-one-add-delay-to-deployment-of-arm-template-resource

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...