2016-11-18 17 views
2

私はAzureに "Web app"を持っています。このWebアプリケーションには、Visual Studioを使って.Net Webアプリケーションを配備/公開しています。 (ビルド - >パブリッシュ)、それが動作します。Powershellを使用して.Net WebアプリケーションをAzureにデプロイする方法

Powershellスクリプトを使用してアプリケーションを展開/公開できるようにします。

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) 
:私はエラーを得た

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 

CMD> "c:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe" WebApplication1.sln 

は、私はいくつかのパラメータを追加する必要があり、それはまた、展開できるようにするには:私は、ビルド部分のために働くために、次のスクリプトを得ました

私は明らかにAzureの資格情報がなくなっています(Visual Studioがそれらを取得できるようになっているのを見て)、Powershellでも実行していません。

だから私は、全体の指揮を執ったし、ファイルに入れて DEPLOY.BAT と呼ばれる、PowerShellウィンドウを開いて、次のことをやった。(私は私のユーザー/パスワードで入力

PS> Login-AzureRmAccount 

GUIポップアップ)。

PS> cmd /c .\deploy.bat 

ビルドは正常でしたが、パブリッシュしようとしたときに同じエラーが発生しました。私はAzureの資格情報がCMDプログラムに砲撃するときに運ばなかったと思います。

私の.NETプロジェクトでMSBuildを呼び出してPowershellを使用してAzure Webアプリケーションに公開するにはどうすればよいですか?

答えて

4

既存の.pubxmlファイルを使用できますが、展開するにはパスワードが必要です。それを得るにはいくつかの方法があります。最も明白な一つは、あなたのブレードのWebアプリに移動し、「詳細」をクリックすることで、ポータルからそれを取得することで、最終的には

enter image description here

「プロファイルを公開しなさい」上でこのファイルには、あらゆる種類のが含まれています必要なパスワードは userPWDとなります。これは使用する必要のあるパスワードです。

CMD> "c:¥Program Files(x86)¥MSBuild¥14.0¥bin¥msbuild.exe" WebApplication1.sln/p:DeployOnBuild = true/p:PublishProfileパスワードをコピーしてMsBuildコマンドに追加します。 Webアプリケーション1 - Webアプリケーション1 - Web Deploy.pubxml "/ p:Configuration = Release /p:Webアプリケーション1 - WebApplication1 \ WebApplication1 \ Properties \ PublishProfiles \ jgodse \パスワード= "userPWDの値"

もちろん、この値をビルドスクリプトに保存することはお勧めできません。 Powershell(Get-AzurePublishSettingsFile)を使用してパブリッシュ設定をダウンロードし、userPWD値を抽出し、MsBuildに渡してアプリを公開し、最後にすべてをクリーンアップすることができます。

インフラストラクチャの構築にはさまざまな方法がありますが、私が提案したものがあなたに最適なソリューションではないかもしれませんが、あなたにとって最適なものを試して決定するのはあなた次第です。

一部のリソース:

Automate Everything (Building Real-World Cloud Apps with Azure) - この1つはASMを使用する代わりに、リソースマネージャがありますが、簡単にARM Using Windows PowerShell scripts to publish to dev and test environments

・ホープこのことができますを使用するように微調整することができます。

+1

ありがとうございます。それはまさに私が必要としたものでした。 –

関連する問題