1

I am trying to deploy app services but I keep getting deployment failure Microsoft.Web/sites/hostNameBindings

Message: Cannot modify this site because another operation is in progress. OperationName: RegisterTrafficManagerProfile, CreatedTime: 5/14/2021 12:03:05 AM, , EntityType: 1. I get this error intermittently.

I read one of the stack overflow answers that it seems Traffic Manager causes a problem with the asynchronous hostNameBindings iteration operation. Which can be resolved by specifying a synchronous copy using "mode": "serial" mode with "batchsize": 1,

I tried this solution but I still get this conflict error, not sure why? anyone ran into same issue where after synchronising the copy getting above error?

Recently we had changes to our template to deploy traffic manager endpoints as separate resource which caused the process to take longer, Does increase in process time can cause conflict? what can be other reasons for this failure?

Any insights into this will be helpful. I am quite new to working on app service arm template

EDIT My current arm template I am just showing hostname bindings and traffic manager profiles {

 "type": "Microsoft.Web/sites/hostNameBindings",
  "apiVersion": "2016-03-01",
  "copy": {
    "name": "hostNameBindingLoop",
    "mode": "serial",
    "batchSize": 1,
    "count": "[length(variables('appServicePlanLocations'))]"
  },
  "name": "[concat(variables('websiteName') [copyIndex()], '/', parameters('cName'))]",
  "location": "[vaiables('appServicePlanLocations')[copyIndex()]]",
  "properties": {
    "sslState": "SniEnabled",
    "thumbprint": "[reference(resourceId('Microsoft.Web/certificates', variables('xyzCertName')[copyIndex()])).Thumbprint]"
  },
  "dependsOn": [
    "[concat('Microsoft.Web/certificates/',variables('xyzCertName'[copyIndex()])]",
  ],
},
{
   "type": "Microsoft.Network/trafficManagerProfiles",
   "apiVersion": "2018-08-01",
    "name": "[parameters('trafficManagerName')]",
    "location": "global",
   "properties": {
    "profileStatus": "Enabled",
    "trafficRoutingMethod":  "Performance",
    "dnsConfig": {
      "relativeName": "[parameters('uniqueDnsName')]",
      "ttl": 300
    },
    "monitorConfig": {
      "protocol": "HTTPS",
      "port": 443,
      "path": "/"
    }
    "endpoints": [],
    "trafficViewEnrollmentStatus": "Disabled
  }

},

{
  "type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints",
  "apiVersion": "2018-08-01",
  "name": "[concat(variables('trafficManager'),'/',variables('websiteName'),  copyIndex(1))]",
  "location": "global",
  "dependsOn": [
    "[concat('Microsoft.Network/trafficManagerProfiles/', variables('trafficManager'))]"
  ],
  "properties": {
    "targetResourceId": "[concat('Microsoft.Web/sites/',variables('websiteName')[copyIndex()])]",'  
    "endpointStatus": "Enabled",
    "endpointLocation": "[vaiables('appServicePlanLocations')[copyIndex()]]"
      },
 "copy": {
    "name": "trafficManagerEndPointLoop",
    "mode": "serial",
    "batchSize": 1,
    "count": "[length(variables('appServicePlanLocations'))]"
  }
}

1 Answers1

0

I assume that you would like to create an Azure Traffic Manager profile with an App Service Behind It. Here is a template for your reference. This automatically provisions a custom domain xxxx.trafficmanager.net in the custom domains settings of your Azure app service.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "uniqueDnsName": {
      "type": "string",
      "metadata": {
        "description": "Relative DNS name for the traffic manager profile, resulting FQDN will be <uniqueDnsName>.trafficmanager.net, must be globally unique."
      }
    },
    "uniqueDnsNameForWebApp": {
      "type": "string",
      "metadata": {
        "description": "Relative DNS name for the WebApps, must be globally unique.  An index will be appended for each Web App."
      }
    },
    "webServerName": {
      "type": "string",
      "metadata": {
        "description": "Name of the App Service Plan that is being created"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    },
    "trafficManagerName": {
      "type": "string",
      "metadata": {
        "description": "Name of the trafficManager being created"
      }
    }
  },

  "variables": {},

  "resources": [
    {
      "type": "Microsoft.Web/serverfarms",
      "apiVersion": "2019-08-01",
      "name": "[parameters('webServerName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "S1",
        "tier": "Standard"
      }
    },
    {
      "type": "Microsoft.Web/sites",
      "apiVersion": "2019-08-01",
      "name": "[parameters('uniqueDnsNameForWebApp')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms/',parameters('webServerName'))]"

      ],
      "properties": {
        "serverFarmId": "[parameters('webServerName')]"
      }
    },
    {
      "type": "Microsoft.Network/trafficManagerProfiles",
      "apiVersion": "2018-08-01",
      "name": "[parameters('trafficManagerName')]",
      "location": "global",
      "properties": {
        "profileStatus": "Enabled",
        "trafficRoutingMethod": "Priority",
        "dnsConfig": {
          "relativeName": "[parameters('uniqueDnsName')]",
          "ttl": 30
        },
        "monitorConfig": {
          "protocol": "HTTPS",
          "port": 443,
          "path": "/"
        }
      }
    },
    {
      "type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints",
      "apiVersion": "2018-08-01",
      "name": "[concat(parameters('trafficManagerName'),'/',parameters('uniqueDnsNameForWebApp'))]",
      "location": "global",
      "dependsOn": [
        "[resourceId('Microsoft.Network/trafficManagerProfiles/',parameters('trafficManagerName'))]",
        "[resourceId('Microsoft.Web/sites/',parameters('uniqueDnsNameForWebApp'))]"
      ],
      "properties": {
        "targetResourceId": "[resourceId('Microsoft.Web/sites/', parameters('uniqueDnsNameForWebApp'))]",
        "endpointStatus": "Enabled"
      }
    }
  ]
}
Nancy
  • 26,865
  • 3
  • 18
  • 34
  • I have added the part of current template which is giving me error and it includes "Microsoft.Network/trafficManagerProfiles" "Microsoft.Network/trafficManagerProfiles/azureEndpoints" resources along with "Microsoft.Web/sites/hostNameBindings". not sure where am I going wrong – Swati Sahay May 14 '21 at 17:29