Search code examples
azureazure-rm-template

ARM Template deployment fails (No route registered for '/MSDeploy')


I try to deploy my Resource Group to the Azure from Visual Studio 2019. Deployment fails with an error below.

00:14:13 - Template deployment returned the following errors:
00:14:13 - 12:14:07 AM - Resource Microsoft.Web/sites/extensions 'azapp-mentoringdemo-020/MSDeploy' failed with message '{
00:14:13 -   "error": {
00:14:13 -     "code": "BadRequest",
00:14:13 -     "message": "No route registered for '/MSDeploy'"
00:14:13 -   }
00:14:13 - }

Important note: this happens only when I deploy to Linux App Service. It looks like Extensions are not available for the Linux app services. Since this is disabled on the portal.

My long ARM Template:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "target_env": {
      "type": "string",
      "allowedValues": [ "dev", "stage", "prod" ],
      "defaultValue": "dev",
      "metadata": {
        "description": "Target Environment (possible values: dev, stage and prod)."
      }
    },
    "azapp_name": {
      "defaultValue": "azapp-mentoringdemo-001",
      "type": "String",
      "metadata": {
        "description": "App Service name."
      }
    },
    "azplan_name": {
      "defaultValue": "azplan-mentoringdemo-001",
      "type": "String",
      "metadata": {
        "description": "Service Plan name."
      }
    },
    "_artifactsLocation": {
      "type": "string"
    },
    "_artifactsLocationSasToken": {
      "type": "securestring"
    },
    "AzureMentoring.WebAppPackageFolder": {
      "type": "string",
      "minLength": 1,
      "metadata": {
        "description": "WebDeploy package location. This path is relative to the _artifactsLocation parameter"
      }
    },
    "AzureMentoring.WebAppPackageFileName": {
      "type": "string",
      "minLength": 1,
      "metadata": {
        "description": "Name of the webdeploy package"
      }
    }
  },
  "variables": {},
  "resources": [
    // Service Plan with sku which supports slots
    {
      "type": "Microsoft.Web/serverfarms",
      "apiVersion": "2018-02-01",
      "name": "[parameters('azplan_name')]",
      "location": "North Europe",
      "sku": {
        "name": "P1v2",
        "tier": "PremiumV2",
        "size": "P1v2",
        "family": "Pv2",
        "capacity": 1
      },
      "kind": "linux",
      "properties": {
        "perSiteScaling": false,
        "maximumElasticWorkerCount": 1,
        "isSpot": false,
        "reserved": true,
        "isXenon": false,
        "hyperV": false,
        "targetWorkerCount": 0,
        "targetWorkerSizeId": 0
      }
    },
    // the App service
    {
      "type": "Microsoft.Web/sites",      
      "apiVersion": "2018-11-01",
      "name": "[parameters('azapp_name')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', parameters('azplan_name'))]"
      ],
      "kind": "app,linux",
      "properties": {
        "enabled": true,
        "hostNameSslStates": [
          {
            "name": "[concat(parameters('azapp_name'), '.azurewebsites.net')]",
            "sslState": "Disabled",
            "hostType": "Standard"
          },
          {
            "name": "[concat(parameters('azapp_name'), '.scm.azurewebsites.net')]",
            "sslState": "Disabled",
            "hostType": "Repository"
          }
        ],
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('azplan_name'))]",
        "reserved": true,
        "isXenon": false,
        "hyperV": false,
        "siteConfig": {
          //appsettings
          "appSettings": [
            {
              "name": "DEPLOYMENT_SLOT_NAME",
              "value": "Production Slot"
            },
            {
              "name": "WEBSITE_WEBDEPLOY_USE_SCM",
              "value": "false"
            }
          ]
        },
        "scmSiteAlsoStopped": false,
        "clientAffinityEnabled": true,
        "clientCertEnabled": false,
        "hostNamesDisabled": false,
        "containerSize": 0,
        "dailyMemoryTimeQuota": 0,
        "httpsOnly": false,
        "redundancyMode": "None"
      },
      "resources": [
        // MSDEPLOY
        {
          "condition": "[equals(parameters('target_env'), 'prod')]",
          "name": "MSDeploy",
          "apiVersion": "2018-11-01",
          "type": "extensions",
          "location": "North Europe",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]"
          ],
          "tags": {
            "displayName": "AzureMentoring.WebApp"
          },
          "properties": {
            "packageUri": "[concat(parameters('_artifactsLocation'), parameters('AzureMentoring.WebAppPackageFolder'), '/', parameters('AzureMentoring.WebAppPackageFileName'), parameters('_artifactsLocationSasToken'))]",
            "dbType": "None",
            "connectionString": "",
            "setParameters": {
              "IIS Web Application Name": "[parameters('azapp_name')]"
            }
          }
        }
      ]
    },
    {
      "type": "Microsoft.Web/sites/config",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/web')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]"
        //"[resourceId('Microsoft.Web/Sites/Extensions', parameters('azapp_name'), 'MSDeploy')]"
      ],
      "properties": {
        "numberOfWorkers": 1,
        "defaultDocuments": [
          "Default.htm",
          "Default.html",
          "Default.asp",
          "index.htm",
          "index.html",
          "iisstart.htm",
          "default.aspx",
          "index.php",
          "hostingstart.html"
        ],
        "netFrameworkVersion": "v4.0",
        "linuxFxVersion": "DOTNETCORE|3.1",
        "requestTracingEnabled": false,
        "remoteDebuggingEnabled": false,
        "remoteDebuggingVersion": "VS2019",
        "httpLoggingEnabled": false,
        "logsDirectorySizeLimit": 35,
        "detailedErrorLoggingEnabled": false,
        "publishingUsername": "$ivanovwebapp",
        "azureStorageAccounts": {},
        "scmType": "None",
        "use32BitWorkerProcess": true,
        "webSocketsEnabled": false,
        "alwaysOn": false,
        "appCommandLine": "dotnet /home/site/wwwroot/AzureMentoring.WebApp.dll",
        "managedPipelineMode": "Integrated",
        "virtualApplications": [
          {
            "virtualPath": "/",
            "physicalPath": "site\\wwwroot",
            "preloadEnabled": false
          }
        ],
        "loadBalancing": "LeastRequests",
        "experiments": {
          "rampUpRules": []
        },
        "autoHealEnabled": false,
        "localMySqlEnabled": false,
        "ipSecurityRestrictions": [
          {
            "ipAddress": "Any",
            "action": "Allow",
            "priority": 1,
            "name": "Allow all",
            "description": "Allow all access"
          }
        ],
        "scmIpSecurityRestrictions": [
          {
            "ipAddress": "Any",
            "action": "Allow",
            "priority": 1,
            "name": "Allow all",
            "description": "Allow all access"
          }
        ],
        "scmIpSecurityRestrictionsUseMain": false,
        "http20Enabled": false,
        "minTlsVersion": "1.2",
        "ftpsState": "AllAllowed",
        "reservedInstanceCount": 0
      }
    },
    {
      "type": "Microsoft.Web/sites/hostNameBindings",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/', parameters('azapp_name'), '.azurewebsites.net')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]"
      ],
      "properties": {
        "siteName": "ivanovwebapp",
        "hostNameType": "Verified"
      }
    },
    // DEV slot
    {
      "type": "Microsoft.Web/sites/slots",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/dev')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]",
        "[resourceId('Microsoft.Web/serverfarms', parameters('azplan_name'))]"
      ],
      "kind": "app,linux",
      "properties": {
        "enabled": true,
        "hostNameSslStates": [
          {
            "name": "ivanovwebapp-dev.azurewebsites.net",
            "sslState": "Disabled",
            "hostType": "Standard"
          },
          {
            "name": "ivanovwebapp-dev.scm.azurewebsites.net",
            "sslState": "Disabled",
            "hostType": "Repository"
          }
        ],
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('azplan_name'))]",
        "reserved": true,
        "isXenon": false,
        "hyperV": false,
        "siteConfig": {
          //appsettings
          "appSettings": [
            {
              "name": "DEPLOYMENT_SLOT_NAME",
              "value": "Development Slot"
            },
            {
              "name": "WEBSITE_WEBDEPLOY_USE_SCM",
              "value": "false"
            }
          ]
        },
        "scmSiteAlsoStopped": false,
        "clientAffinityEnabled": true,
        "clientCertEnabled": false,
        "hostNamesDisabled": false,
        "containerSize": 0,
        "dailyMemoryTimeQuota": 0,
        "httpsOnly": false,
        "redundancyMode": "None"
      },
      "resources": [
        // MSDEPLOY
        {
          "condition": "[equals(parameters('target_env'), 'dev')]",
          "name": "MSDeploy",
          "type": "Extensions",
          "apiVersion": "2018-11-01",
          "location": "North Europe",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), 'dev')]"
          ],
          "tags": {
            "displayName": "devMSDeploy"
          },
          "properties": {
            "packageUri": "[concat(parameters('_artifactsLocation'), '/', parameters('AzureMentoring.WebAppPackageFolder'), '/', parameters('AzureMentoring.WebAppPackageFileName'), parameters('_artifactsLocationSasToken'))]",
            "dbType": "None",
            "connectionString": "",
            "setParameters": {
              "IIS Web Application Name": "[concat(parameters('azapp_name'), '/dev')]"
            }
          }
        }
      ]
    },
    // STAGE slot
    {
      "type": "Microsoft.Web/sites/slots",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/stage')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]",
        "[resourceId('Microsoft.Web/serverfarms', parameters('azplan_name'))]"
      ],
      "kind": "app,linux",
      "properties": {
        "enabled": true,
        "hostNameSslStates": [
          {
            "name": "ivanovwebapp-stage.azurewebsites.net",
            "sslState": "Disabled",
            "hostType": "Standard"
          },
          {
            "name": "ivanovwebapp-stage.scm.azurewebsites.net",
            "sslState": "Disabled",
            "hostType": "Repository"
          }
        ],
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('azplan_name'))]",
        "reserved": true,
        "isXenon": false,
        "hyperV": false,
        "siteConfig": {
          //appsettings
          "appSettings": [
            {
              "name": "DEPLOYMENT_SLOT_NAME",
              "value": "Staging Slot"
            },
            {
              "name": "WEBSITE_WEBDEPLOY_USE_SCM",
              "value": "false"
            }
          ]
        },
        "scmSiteAlsoStopped": false,
        "clientAffinityEnabled": true,
        "clientCertEnabled": false,
        "hostNamesDisabled": false,
        "containerSize": 0,
        "dailyMemoryTimeQuota": 0,
        "httpsOnly": false,
        "redundancyMode": "None"
      },
      "resources": [
        // MSDEPLOY
        {
          "condition": "[equals(parameters('target_env'), 'stage')]",
          "name": "MSDeploy",
          "type": "Extensions",
          "apiVersion": "2018-11-01",
          "location": "North Europe",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), 'stage')]"
          ],
          "tags": {
            "displayName": "stageMSDeploy"
          },
          "properties": {
            "packageUri": "[concat(parameters('_artifactsLocation'), '/', parameters('AzureMentoring.WebAppPackageFolder'), '/', parameters('AzureMentoring.WebAppPackageFileName'), parameters('_artifactsLocationSasToken'))]",
            "dbType": "None",
            "connectionString": "",
            "setParameters": {
              "IIS Web Application Name": "[concat(parameters('azapp_name'), '/stage')]"
            }
          }
        }
      ]
    },
    {
      "type": "Microsoft.Web/sites/slots/config",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/dev/web')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), 'dev')]",
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]"//,
        //"[resourceId('Microsoft.Web/Sites/Slots/Extensions', parameters('azapp_name'), 'dev', 'MSDeploy')]"
      ],
      "properties": {
        "numberOfWorkers": 1,
        "defaultDocuments": [
          "Default.htm",
          "Default.html",
          "Default.asp",
          "index.htm",
          "index.html",
          "iisstart.htm",
          "default.aspx",
          "index.php",
          "hostingstart.html"
        ],
        "netFrameworkVersion": "v4.0",
        "linuxFxVersion": "DOTNETCORE|3.1",
        "requestTracingEnabled": false,
        "remoteDebuggingEnabled": false,
        "remoteDebuggingVersion": "VS2019",
        "httpLoggingEnabled": false,
        "logsDirectorySizeLimit": 35,
        "detailedErrorLoggingEnabled": false,
        "publishingUsername": "$ivanovwebapp__dev",
        "azureStorageAccounts": {},
        "scmType": "None",
        "use32BitWorkerProcess": true,
        "webSocketsEnabled": false,
        "alwaysOn": false,
        "appCommandLine": "dotnet /home/site/wwwroot/AzureMentoring.WebApp.dll",
        "managedPipelineMode": "Integrated",
        "virtualApplications": [
          {
            "virtualPath": "/",
            "physicalPath": "site\\wwwroot",
            "preloadEnabled": false
          }
        ],
        "loadBalancing": "LeastRequests",
        "experiments": {
          "rampUpRules": []
        },
        "autoHealEnabled": false,
        "localMySqlEnabled": false,
        "ipSecurityRestrictions": [
          {
            "ipAddress": "Any",
            "action": "Allow",
            "priority": 1,
            "name": "Allow all",
            "description": "Allow all access"
          }
        ],
        "scmIpSecurityRestrictions": [
          {
            "ipAddress": "Any",
            "action": "Allow",
            "priority": 1,
            "name": "Allow all",
            "description": "Allow all access"
          }
        ],
        "scmIpSecurityRestrictionsUseMain": false,
        "http20Enabled": false,
        "minTlsVersion": "1.2",
        "ftpsState": "AllAllowed",
        "reservedInstanceCount": 0
      }
    },
    {
      "type": "Microsoft.Web/sites/slots/config",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/stage/web')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), 'stage')]",
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]"//,
        //"[resourceId('Microsoft.Web/Sites/Slots/Extensions', parameters('azapp_name'), 'stage', 'MSDeploy')]"
      ],
      "properties": {
        "numberOfWorkers": 1,
        "defaultDocuments": [
          "Default.htm",
          "Default.html",
          "Default.asp",
          "index.htm",
          "index.html",
          "iisstart.htm",
          "default.aspx",
          "index.php",
          "hostingstart.html"
        ],
        "netFrameworkVersion": "v4.0",
        "linuxFxVersion": "DOTNETCORE|3.1",
        "requestTracingEnabled": false,
        "remoteDebuggingEnabled": false,
        "remoteDebuggingVersion": "VS2019",
        "httpLoggingEnabled": false,
        "logsDirectorySizeLimit": 35,
        "detailedErrorLoggingEnabled": false,
        "publishingUsername": "$ivanovwebapp__stage",
        "azureStorageAccounts": {},
        "scmType": "None",
        "use32BitWorkerProcess": true,
        "webSocketsEnabled": false,
        "alwaysOn": false,
        "appCommandLine": "dotnet /home/site/wwwroot/AzureMentoring.WebApp.dll",
        "managedPipelineMode": "Integrated",
        "virtualApplications": [
          {
            "virtualPath": "/",
            "physicalPath": "site\\wwwroot",
            "preloadEnabled": false
          }
        ],
        "loadBalancing": "LeastRequests",
        "experiments": {
          "rampUpRules": []
        },
        "autoHealEnabled": false,
        "localMySqlEnabled": false,
        "ipSecurityRestrictions": [
          {
            "ipAddress": "Any",
            "action": "Allow",
            "priority": 1,
            "name": "Allow all",
            "description": "Allow all access"
          }
        ],
        "scmIpSecurityRestrictions": [
          {
            "ipAddress": "Any",
            "action": "Allow",
            "priority": 1,
            "name": "Allow all",
            "description": "Allow all access"
          }
        ],
        "scmIpSecurityRestrictionsUseMain": false,
        "http20Enabled": false,
        "minTlsVersion": "1.2",
        "ftpsState": "AllAllowed",
        "reservedInstanceCount": 0
      }
    },
    {
      "type": "Microsoft.Web/sites/slots/hostNameBindings",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/dev/', parameters('azapp_name'), '-dev.azurewebsites.net')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), 'dev')]",
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]"
      ],
      "properties": {
        "siteName": "ivanovwebapp(dev)",
        "hostNameType": "Verified"
      }
    },
    {
      "type": "Microsoft.Web/sites/slots/hostNameBindings",
      "apiVersion": "2018-11-01",
      "name": "[concat(parameters('azapp_name'), '/stage/', parameters('azapp_name'), '-stage.azurewebsites.net')]",
      "location": "North Europe",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), 'stage')]",
        "[resourceId('Microsoft.Web/sites', parameters('azapp_name'))]"
      ],
      "properties": {
        "siteName": "ivanovwebapp(stage)",
        "hostNameType": "Verified"
      }
    }
  ],
  "outputs": {
    // Значения имени среды (dev/stage/prod)
    "target_env_name": {
      "type": "string",
      "value": "[parameters('target_env')]",
      "metadata": {
        "description": "Target Environment name."
      }
    },
    // Полного доменного имени вашего приложения с учётом текущей среды
    "target_env_app_url_prod": {
      "condition": "[equals(parameters('target_env'), 'prod')]",
      "type": "string",
      "value": "[concat('http://', parameters('azapp_name'), '-', parameters('target_env'), '.azurewebsites.net')]",
      "metadata": {
        "description": "Target Environment web site url(concat result)."
      }
    },
    "target_env_app_url": {
      "condition": "[or(equals(parameters('target_env'), 'dev'), equals(parameters('target_env'), 'stage'))]",
      "type": "string",
      "value": "[concat('http://', parameters('azapp_name'), '-', parameters('target_env'), '.azurewebsites.net')]",
      "metadata": {
        "description": "Target Environment web site url(concat result)."
      }
    },
    "target_env_real_app_url": {
      "condition": "[or(equals(parameters('target_env'), 'dev'), equals(parameters('target_env'), 'stage'))]",
      "type": "array",
      "value": "[reference(resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), parameters('target_env'))).HostNames]",
      "metadata": {
        "description": "Target Environment web site url(reference result)."
      }
    },
    // Публичный IP-адрес текущей среды
    // https://stackoverflow.com/questions/40488443/how-can-i-determine-the-ip-address-of-an-azure-hosted-webapp
    // https://learn.microsoft.com/ru-ru/azure/app-service/overview-inbound-outbound-ips
    "target_env_pip": {
      "condition": "[or(equals(parameters('target_env'), 'dev'), equals(parameters('target_env'), 'stage'))]",
      "type": "string",
      // https://learn.microsoft.com/ru-ru/azure/azure-resource-manager/templates/template-functions-resource#resourceid
      "value": "[reference(resourceId('Microsoft.Web/sites/slots', parameters('azapp_name'), parameters('target_env'))).OutboundIpAddresses]",
      "metadata": {
        "description": "Public IP Addresses of Target Environment."
      }
    }
  }
}


Solution

  • Based on the name MSDeploy I would believe that this extension is for Microsoft eg. Windows Server and not for Linux. Many Extensions are available for both Linux and Windows but its normally different extensions. So you need to search for a Linux version of that extension to make it work.

    To get all available extensions in a region you can do like this:

    Get-AzVMImagePublisher -Location "West US" | Get-AzVMExtensionImageType | Get-AzVMExtensionImage | select PublisherName, Type, Version