我在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應用程序?
謝謝。那正是我需要的。 –