使用MSDeploy将web应用程序部署到Azure应用程序服务

使用MSDeploy将web应用程序部署到Azure应用程序服务,azure,azure-web-app-service,msdeploy,Azure,Azure Web App Service,Msdeploy,使用MSDeploy将我的web应用程序部署到Azure应用程序服务时遇到很多问题。我需要使用哪些命令行参数?MSDeploy对接受参数的方式有点挑剔。首先,该命令需要您的应用程序服务的用户名和密码。这可以通过在PowerShell中使用Azure CLI找到,如下所示: $publishProfile=az webapp部署列表发布配置文件--资源组--名称--查询“[?publishMethod=='MSDeploy']”转换自Json 这将把用户名和密码放入$publishProfile

使用MSDeploy将我的web应用程序部署到Azure应用程序服务时遇到很多问题。我需要使用哪些命令行参数?

MSDeploy对接受参数的方式有点挑剔。首先,该命令需要您的应用程序服务的用户名和密码。这可以通过在PowerShell中使用Azure CLI找到,如下所示:

$publishProfile=az webapp部署列表发布配置文件--资源组--名称--查询“[?publishMethod=='MSDeploy']”转换自Json
这将把用户名和密码放入
$publishProfile
变量中,以便稍后与MSDeploy一起使用

接下来,如果源发布网站的路径中有空格,并且正在使用PowerShell,则需要将其转换为等效的短名称语法。如果不这样做,MSDeploy将抛出一些毫无意义的异常,比如下面这些异常很难诊断

错误代码:找不到错误\u提供程序\u 详细信息:找不到提供程序“dirPath=”。有关详细信息,请访问:。 位于Microsoft.Web.Deployment.DeploymentProviderSettingCollection..ctor(字符串factoryName) 位于Microsoft.Web.Deployment.DeploymentProviderOptions..ctor(字符串factoryName) 位于MSDeploy.MSDeploy.GetObjectParameters(字典'2参数、布尔值isDestination、DeploymentBaseOptions和retbaseOptions、DeploymentProviderOptions和retproviderOptions) 在MSDeploy.MSDeploy.ExecuteWorker()上 在MSDeploy.MSDeploy.Execute()处 位于MSDeploy.MSDeploy.Main(字符串[]unusedArgs) 错误计数:1

要将路径转换为其等效的短名称,请使用以下命令:

$shortPath=(新对象-coobject Scripting.FileSystemObject.GetFolder(“.\Publish”).shortPath
最后,这里是运行MSDeploy并将web应用程序部署到Azure的命令。要使用下面的命令,需要定义
$webAppName
变量

$webAppName=“MyWebApp”
&“C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe”-动词:sync-source:dirPath=“$shortPath”,includeAcls=false-dest:dirPath=D:\home\site\wwwroot,ComputerName=“https://$webAppName.scm.azurewebsites.net/msdeploy.axd?site=$($webAppName)”,UserName=$($publishProfile.UserName),Password=$($publishProfile.userPWD),AuthType='Basic'-verbose-debug
该命令应返回类似以下内容的输出:

Info: Using ID 'd5e5eb3d-...' for connections to the remote server.
Verbose: Pre-authenticating to remote agent URL 'https://webappname.scm.azurewebsites.net/msdeploy.axd?site=webappname' as '$webappname'.
Verbose: Performing synchronization pass #1.
Verbose: Pre-authenticating to remote agent URL 'https://webappname.scm.azurewebsites.net/msdeploy.axd?site=webappname' as '$webappname'.
Verbose: Received response from agent (HTTP status 'OK').
Info: Adding directory (D:\home\site\wwwroot\cs).
Info: Adding directory (D:\home\site\wwwroot\de).
Info: Adding directory (D:\home\site\wwwroot\es).
Info: Adding directory (D:\home\site\wwwroot\fr).
Info: Deleting file (D:\home\site\wwwroot\hostingstart.html).
Info: Adding directory (D:\home\site\wwwroot\it).
Info: Adding directory (D:\home\site\wwwroot\ja).
Info: Adding directory (D:\home\site\wwwroot\ko).
Info: Adding directory (D:\home\site\wwwroot\pl).
Info: Adding directory (D:\home\site\wwwroot\pt-BR).
Info: Adding directory (D:\home\site\wwwroot\ru).
Info: Adding directory (D:\home\site\wwwroot\runtimes).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix\lib).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix\lib\netcoreapp2.0).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix\lib\netcoreapp2.1).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib\netcoreapp2.0).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib\netcoreapp2.1).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib\netstandard2.0).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-arm64).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-arm64\native).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x64).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x64\native).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x86).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x86\native).
Info: Adding directory (D:\home\site\wwwroot\tr).
Info: Adding directory (D:\home\site\wwwroot\zh-Hans).
Info: Adding directory (D:\home\site\wwwroot\zh-Hant).
Verbose: The dependency check 'DependencyCheckInUse' found no issues.
Verbose: The current synchronization pass is missing stream content for 201 objects.
Info: Using ID '1f1ab053-88c6-40a2-90e4-5347157542e6' for connections to the remote server.
Verbose: Performing synchronization pass #2.
Verbose: Pre-authenticating to remote agent URL 'https://webappname.scm.azurewebsites.net/msdeploy.axd?site=webappname' as '$webappname'.
...
Verbose: The HTTP connection (ID='1f1ab053-88c6-40a2-90e4-5347157542e6', type ='GetTraceStatus') is being kept alive while the request is processed.
Verbose: Received response from agent (HTTP status 'OK').
...
Verbose: The dependency check 'DependencyCheckInUse' found no issues.
Verbose: The synchronization completed in 2 pass(es).
Total changes: 231 (230 added, 1 deleted, 0 updated, 0 parameters changed, 44498979 bytes copied)