MSDeploy to Azure Web App: Could not connect to the remote computer using the specified process (“Web Management Service”)

狂风中的少年 提交于 2019-12-12 13:31:56

问题


We publish to our Azure Web App using MSBuild MSDeploy in VSO/VSTS Build (vNext) using the script below. This works well.

BUT, when assigning the Azure Web App to a custom domain (through the Azure Portal), the publish fails.

VSTS Build error on MSDeploy:

Publishing with publish method [MSDeploy] Executing command ["C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:IisApp='C:\a\8b0700fff\MrProjectMain\Api\wwwroot' -dest:IisApp='myproject-prod-webapp',ComputerName='https://myproject-prod-webapp.azurewebsites.net/msdeploy.axd',UserName='$myproject-prod-webapp',Password='{PASSWORD-REMOVED-FROM-LOG}',IncludeAcls='False',AuthType='Basic' -verb:sync -enableLink:contentLibExtension -retryAttempts:2 -disablerule:BackupRule]
[error]Error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC
[error]More Information: Could not connect to the remote computer ("myproject-prod-webapp.azurewebsites.net") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC. [error]Error: The remote server returned an error: (403) Forbidden.
[error]Error count: 1.

Azure portal custom domain setup:

Publish script:

param($websiteName, $packOutput)

$website = Get-AzureWebsite -Name $websiteName
$msdeployurl = $website.EnabledHostNames[1]

$publishProperties = @{'WebPublishMethod'='MSDeploy';
                        'MSDeployServiceUrl'=$msdeployurl;
                        'DeployIisAppPath'=$website.Name;
                        'Username'=$website.PublishingUsername;
                        'Password'=$website.PublishingPassword;
                        'SkipExtraFilesOnServer'='False';
                        'AllowUntrustedCertificate'='True'}

Write-Output "Publishing web app..."
$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"
. $publishScript -publishProperties $publishProperties  -packOutput $packOutput

回答1:


The issue is here:

$msdeployurl = $website.EnabledHostNames[1]

By default, the MSDeploy SCM URL is the second in the EnabledHostNames array. So it works by default. But it may not work as soon as you made some changes to your web app. According to the logs you provided, MSDeploy is trying to connect to "https://myproject-prod-webapp.azurewebsites.net/msdeploy.axd", this is not a SCM URL. The SCM URL should like this: "https://myproject-prod-webapp.scm.azurewebsites.net/msdeploy.axd". So you need to check what is the correct scm URL array number now. You can add the code like following in the PowerShell script to see which one is the scm URL and then update the script accordingly.

Write-Output $website.EnabledHostNames[0]
Write-Output $website.EnabledHostNames[1]
Write-Output $website.EnabledHostNames[2]
...

You can also refer to this article to update your script to get the correct SCM url automatically.



来源:https://stackoverflow.com/questions/34435909/msdeploy-to-azure-web-app-could-not-connect-to-the-remote-computer-using-the-sp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!