问题描述
我尝试将资源组从Visual Studio 2019部署到Azure。部署失败,并出现以下错误。
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 - }
重要说明:仅当我部署到Linux App Service时,才会发生这种情况。扩展程序似乎不适用于Linux应用程序服务。由于已在门户网站上将其禁用。
我的长ARM模板:
{
"$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","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","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')]","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')]","hostType": "Repository"
}
],"serverFarmId": "[resourceId('Microsoft.Web/serverfarms',parameters('azplan_name'))]","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","type": "extensions","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","name": "[concat(parameters('azapp_name'),'/web')]","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","scmIpSecurityRestrictionsUseMain": false,"http20Enabled": false,"minTlsVersion": "1.2","ftpsState": "AllAllowed","reservedInstanceCount": 0
}
},{
"type": "Microsoft.Web/sites/hostNameBindings",parameters('azapp_name'))]"
],"properties": {
"siteName": "ivanovwebapp","hostNameType": "Verified"
}
},// DEV slot
{
"type": "Microsoft.Web/sites/slots",'/dev')]",parameters('azapp_name'))]","[resourceId('Microsoft.Web/serverfarms',"hostNameSslStates": [
{
"name": "ivanovwebapp-dev.azurewebsites.net",{
"name": "ivanovwebapp-dev.scm.azurewebsites.net","value": "Development Slot"
},'dev')]","type": "Extensions","dependsOn": [
"[resourceId('Microsoft.Web/sites/slots','dev')]"
],"tags": {
"displayName": "devMSDeploy"
},"setParameters": {
"IIS Web Application Name": "[concat(parameters('azapp_name'),'/dev')]"
}
}
}
]
},// STAGE slot
{
"type": "Microsoft.Web/sites/slots",'/stage')]","hostNameSslStates": [
{
"name": "ivanovwebapp-stage.azurewebsites.net",{
"name": "ivanovwebapp-stage.scm.azurewebsites.net","value": "Staging Slot"
},'stage')]",'stage')]"
],"tags": {
"displayName": "stageMSDeploy"
},'/stage')]"
}
}
}
]
},{
"type": "Microsoft.Web/sites/slots/config",'/dev/web')]","dependsOn": [
"[resourceId('Microsoft.Web/sites/slots',"[resourceId('Microsoft.Web/sites',parameters('azapp_name'))]"//,//"[resourceId('Microsoft.Web/Sites/Slots/Extensions','dev',"publishingUsername": "$ivanovwebapp__dev",'/stage/web')]",'stage',"publishingUsername": "$ivanovwebapp__stage",{
"type": "Microsoft.Web/sites/slots/hostNameBindings",'/dev/','-dev.azurewebsites.net')]","properties": {
"siteName": "ivanovwebapp(dev)",'/stage/','-stage.azurewebsites.net')]","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'),"type": "string","value": "[concat('http://','-',parameters('target_env'),"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'))]","target_env_real_app_url": {
"condition": "[or(equals(parameters('target_env'),"type": "array","value": "[reference(resourceId('Microsoft.Web/sites/slots',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://docs.microsoft.com/ru-ru/azure/app-service/overview-inbound-outbound-ips
"target_env_pip": {
"condition": "[or(equals(parameters('target_env'),// https://docs.microsoft.com/ru-ru/azure/azure-resource-manager/templates/template-functions-resource#resourceid
"value": "[reference(resourceId('Microsoft.Web/sites/slots',parameters('target_env'))).OutboundIpAddresses]","metadata": {
"description": "Public IP Addresses of Target Environment."
}
}
}
}
解决方法
基于名称MSDeploy,我相信此扩展适用于Microsoft,例如。 Windows Server,不适用于Linux。 Linux和Windows都可以使用许多扩展名,但是它们通常是不同的扩展名。因此,您需要搜索该扩展程序的Linux版本才能使其正常工作。
要获取某个地区的所有可用扩展程序,您可以这样操作:
Get-AzVMImagePublisher -Location "West US" | Get-AzVMExtensionImageType | Get-AzVMExtensionImage | select PublisherName,Type,Version