ARM template deployment of Microsoft.Web/sites/hostNameBindings resources using copy
<p>I use a copy operation over an array of Azure data center locations in order to deploy an app service plan and a website per location.  I am able to create a traffic manager profile and use the copy object to add an endpoint per location to the traffic manager profile.</p>

<p>When I try to set the CNAME for each of the web sites to my custom domain name, using the Microsoft.Web/sites/hostNameBindings resource per the instructions <a href="https://github.com/Azure/azure-content/blob/master/articles/app-service-web/app-service-web-arm-with-msdeploy-provision.md#create-arm-template" rel="nofollow">here</a> I came up with the following: </p>

<pre><code>   {
      "type": "Microsoft.Web/sites/hostNameBindings",
      "apiVersion": "[parameters('hostNameBindingsApiVersion')]",
      "copy": {
        "name": "hostNameBindingsEndpointsLoop",
        "count": "[length(parameters('appServicePlanLocations'))]"
      },
      "name": "[concat(concat(variables('webSitePrefix'), parameters('appServicePlanLocations')[copyIndex()]), '/', variables('hostNameBindingsName'))]",
      "location": "[parameters('appServicePlanLocations')[copyIndex()]]",
      "dependsOn": [
        "[concat('Microsoft.Network/trafficManagerProfiles/', variables('trafficManagerName'), '/azureEndpoints/', variables('trafficManagerEndpointPrefix'), parameters('appServicePlanLocations')[copyIndex()])]",
        "[concat('Microsoft.Web/sites/', concat(variables('webSitePrefix'), parameters('appServicePlanLocations')[copyIndex()]))]"
      ],
      "properties": {
        "siteName": "[concat(variables('webSitePrefix'), parameters('appServicePlanLocations')[copyIndex()])]",
        "domainId": null,
        "hostNameType": "Verified"
      }
    }
</code></pre>

<p>Using this, the CNAME is actually set but the ARM template deployment fails with the following error:</p>

<pre><code>{
      "ErrorEntity": {
        "Code": "Conflict",
        "Message": "Cannot modify this site because another operation is in progress. Details: Id: {guid}, OperationName: RegisterTrafficManagerProfile, CreatedTime: 5/24/2016 11:13:54 PM, RequestId: {guid}, EntityType: 1",
        "ExtendedCode": "59203",
        "MessageTemplate": "Cannot modify this site because another operation is in progress. Details: {0}",
        "Parameters": [
          "Id: {guid}, OperationName: RegisterTrafficManagerProfile, CreatedTime: 5/24/2016 11:13:54 PM, RequestId:{guid}, EntityType: 1"
        ],
        "InnerErrors": null
      }
    }
  ],
  "Innererror": null
}
</code></pre>

<p>I'm not sure what the conflict is because I've added the dependson segment to attempt to wait for both the website to be created as well as the trafficmanagerendpoint to complete its provisioning.  I'm going to try to change the order such that after the website is created, I'll add the CNAME and then have the traffic manager endpoint await the CNAME creation.  I don't see why the order should make a difference.</p>

<p>Have I defined the Microsoft.Web/sites/hostNameBindings section of my arm template correctly?  Does the dependson order matter in this scenario?  Should it?</p>