我在Azure中使用Visual Studio部署/发布.Net Web应用程序的“Web应用程序”。 (生成 - >发布),它的工作原理。如何使用Powershell将.Net Web应用程序部署到Azure
我希望能够使用Powershell脚本部署/发布我的应用程序。我得到了下面的脚本程序生成部分工作:
CMD> "c:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe" WebApplication1.sln
为了使它还部署,我需要添加一些参数:
CMD> "c:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe" WebApplication1.sln /p:DeployOnBuild=true /p:PublishProfile="C:\Users\jgodse\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1\Properties\PublishProfiles\jg-7-web-app-1 - Web Deploy.pubxml" /p:Configuration=Release
我得到了一个错误:
Build FAILED.
"c:\Users\jgodse\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1.sln" (default target) (1) ->
"c:\Users\jgodse\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1\WebApplication1.csproj" (default target) (2) ->
(MSDeployPublish target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4295,5): msdeploy error ERROR_USER_UNAUTHORIZED: Web deployment task failed. (Connected to the remote computer ("jg-7-web-app-1.scm.azurewebsites.net") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.) [c:\Users\jgodse\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1\WebApplication1.csproj]
0 Warning(s)
1 Error(s)
我明显缺少Azure证书(因为Visual Studio能够捕获它们),而且我也没有在Powershell中运行。
所以我把整个命令,并把它变成一个名为DEPLOY.BAT文件,开辟了PowerShell窗口,并做了以下内容:
PS> Login-AzureRmAccount
(我在用户名/密码的输入GUI弹出)。
PS> cmd /c .\deploy.bat
构建没问题,但尝试发布时出现同样的错误。我猜这些Azure证书在CMD程序中退出时并未实现。
如何使用Powershell在我的.Net项目上调用MSBuild以发布到Azure Web应用程序?
谢谢。那正是我需要的。 –