4

我正在尝试在命令行中使用 msbuild 工具部署我的 webproject,如下所示 -

msbuild MyWebProject.vbproj /p:DeployOnBuild=true /p:PublishProfile="MyWebProject - Web 部署 - 测试" /p:Configuration=Debug

但我收到以下错误 -

msdeploy 错误 ERROR_COULD_NOT_CONNECT_TO_REMOTESVC:Web 部署任务失败。(无法使用指定进程(“Web 管理服务”)连接到远程计算机(“MyWebProject.scm.azurewebsites.net”),因为服务器没有响应。请确保进程(“Web 管理服务”)是在远程计算机上启动。了解更多信息:http: //go.microsoft.com/fwlink/ ?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC。)[C:\XXXX\XXXX\MyWebProjectSolution\MyWebProject\MyWebProject.Web.vbproj]

这是我正在使用的发布配置文件 -

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <ADUsesOwinOrOpenIdConnect>False</ADUsesOwinOrOpenIdConnect>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://MyWebProject.azurewebsites.net/tMyApp</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>MyWebProject.scm.azurewebsites.net:443</MSDeployServiceURL>
    <DeployIisAppPath>MyWebProject/tMyApp</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>$MyWebProject</UserName>
    <_SavePWD>True</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
    <PublishDatabaseSettings>
        ......
    </PublishDatabaseSettings>
  </PropertyGroup>
  <ItemGroup>
    <MSDeployParameterValue Include="$(DeployParameterPrefix)MyWebProjectDB-Web.config Connection String">
      <UpdateDestWebConfig>False</UpdateDestWebConfig>
    </MSDeployParameterValue>
  </ItemGroup>
</Project>

当我使用相同的发布配置文件手动发布我的网络应用程序时,它工作得很好。

这是 msbuild 发出的请求和响应(使用 fiddler 捕获)-

------- Raw Request -----
CONNECT MyWebProject.scm.azurewebsites.net:443 HTTP/1.1
Host: MyWebProject.scm.azurewebsites.net
Proxy-Connection: Keep-Alive
------- Auth -----
No Proxy-Authorization Header is present.
No Authorization Header is present.

------- Raw Response -----
HTTP/1.1 0 Connection passed to Gateway - Result unknown
EndTime: 10:26:35.164

有关提琴手请求的详细信息,请参见下图。在此处输入图像描述

知道我的 msbuild 命令可能出了什么问题吗?

4

1 回答 1

0

我遇到了这个问题,对我来说,解决方法是将我的 ip 添加到 SCM 站点限制:

Azure portal -> Your app service -> Networking -> Configure Access Restrictions -> scm tab -> Add rule

https://docs.microsoft.com/en-us/azure/app-service/app-service-ip-restrictions#restrict-access-to-an-scm-site

于 2021-02-09T21:06:30.497 回答