4
votes

I am trying to deploy my webproject using msbuild tool in command line as shown below -

msbuild MyWebProject.vbproj /p:DeployOnBuild=true /p:PublishProfile="MyWebProject - Web Deploy - Test" /p:Configuration=Debug

But I am getting following error -

msdeploy error ERROR_COULD_NOT_CONNECT_TO_REMOTESVC: Web deployment task failed. (Could not connect to the remote computer ("MyWebProject.scm.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.) [C:\XXXX\XXXX\MyWebProjectSolution\MyWebProject\MyWebProject.Web.vbproj]

Here is the Publish Profile I am using -

<?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>

When I manually publish my web app using the same publish profile file, it works just fine.

Here is the request and Response msbuild makes (captured using 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

Please see the image below for details of fiddler request.enter image description here

Any idea what might be going wrong with my msbuild command ?

1
What happens if you try navigating to MyWebProject.scm.azurewebsites.net from your browser? Does it also fail, or does it go to the Kudu UI?David Ebbo
This is strange that you can access scm endpoint via browser but that it fails to connect via msbuild. Can you try running fiddler in the failure case to see what request it's making? It could be some kind of proxy issue.David Ebbo
@DavidEbbo Thanks! I will try and update the postGaurav
@DavidEbbo: I have updated the question with fiddler response.Gaurav
You're showing the request, but not the response. Does fiddler show a connection error? Also, how does this request in fiddler compare to the one you make from the browser? Yet another test is to try from curl from the command line. e.g. Try running: curl -u yourusername transactiongateway.scm.azurewebsites.netDavid Ebbo

1 Answers

0
votes

I ran into this issue, for me the fix was to add my ip to the SCM site restrictions:

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