我正在创建一个新的 Azure DevOps 管道以部署到 Linux 应用程序计划,并为此使用 YAML 脚本。
我使用 ARM 模板创建一个网站,其中用于创建插槽的部分是 此 YAML 调用 ARM 模板:
- task: AzureResourceGroupDeployment@2
displayName: 'Create APP Service'
inputs:
azureSubscription: '${{ parameters.AzureSub }}'
resourceGroupName: $(Environment.Name)-WebAppResGrp
location: '${{ parameters.Location }}'
csmFile: '$(Pipeline.Workspace)/ARM_Templates/Templates/WebApp.Template.json'
csmParametersFile: '$(Pipeline.Workspace)/ARM_Templates/WebApp.$(Environment.Name).json'
这是 ARM 创建 Web 应用程序的部分:
{
"apiVersion": "2018-11-01",
"name": "[parameters('webSiteName')]",
"type": "Microsoft.Web/sites",
.....,
"resources": [
{
"condition": "[parameters('slotsEnabled')]",
"type": "slots",
"apiVersion": "2015-08-01",
"name": "staging",
"tags": {
"displayName": "Staging Slot"
},
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('webSiteName'))]"
],
"properties": {
},
"resources": []
}
]
应用程序已创建正常,带有暂存槽。但是,当我尝试使用此代码从 yaml 部署时
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy App to Staging slot'
inputs:
azureSubscription: '${{ parameters.AzureSub }}'
WebAppName: '$(Environment.Name)-Lab1'
deployToSlotOrASE: true
ResourceGroupName: $(Environment.Name)-WebAppResGrp
SlotName: staging
packageForLinux: '$(Pipeline.Workspace)/App/source'
enableCustomDeployment: true
TakeAppOfflineFlag: false
RemoveAdditionalFilesFlag: true
ExcludeFilesFromAppDataFlag: false
我有这个错误:
Could not connect to the remote computer ("<environment name>-<app name>-staging.scm.azurewebsites.net"). On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started. Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.
Error: The remote server returned an error: (404) Not Found.
当我转到 Azure 门户中的插槽时,它的 URL 是
<environment name>-<app name>-staging.azurewebsites.net
- “.scm
”之前没有 .azurewebsites.net
我现在可以修复部署槽 URL 或部署代码的 url,但我找不到如何指定其中任何一个。
我想避免指定唯一的后缀名称。如果有必要的话我会这么做,但这将是最后的手段。
为什么 URL 彼此不匹配以及最好的解决方法是什么?
编辑:我错过了一条重要信息,该应用程序部署的操作系统是Linux。
我在 Linux 操作系统上创建了一个 Azure Web 应用程序。
当我使用与您相同的配置设置 AzureRmWebAppDeployment@4 任务时,我会出现相同的 ERROR_DESTINATION_NOT_REACHABLE 错误。
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'myArmConnection'
WebAppName: 'BriRanApp01'
deployToSlotOrASE: true
ResourceGroupName: 'myResourceGroup'
SlotName: 'staging'
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
enableCustomDeployment: true
TakeAppOfflineFlag: false
RemoveAdditionalFilesFlag: true
ExcludeFilesFromAppDataFlag: false
我更改如下配置后,错误得到修复。
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'myArmConnection'
appType: 'webAppLinux'
WebAppName: 'BriRanApp01'
deployToSlotOrASE: true
ResourceGroupName: 'myResourceGroup'
SlotName: 'staging'
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
enableCustomDeployment: true
TakeAppOfflineFlag: false
RemoveAdditionalFilesFlag: true
ExcludeFilesFromAppDataFlag: false
错误的原因是,如果您在 AzureRmWebAppDeployment@4
任务上省略 '
appType
'(应用程序服务类型)选项,它将应用默认值 'webApp
'( Windows 上的 Web 应用程序)这与实际应用程序类型“webAppLinux
”(Linux 上的 Web 应用程序)不一致。
因此,如果实际的应用程序类型不是“
webApp
”,则需要使用“appType
”选项在任务上显式指定正确的类型。