トップ回答者
Visual Studioの発行でAntimalwareを有効化したい

質問
-
お世話になります。
Cloud ServicesでVisual Studioからの発行時にAntimalwareを有効化する方法を調べています。
ローカルPCから、Azure PowerShellを使用しAntimalware有効化を行えることは確認できました。
その際、使用したコマンドをps1にまとめ、設定ファイルと共にプロジェクトへ追加し、ServiceDefinition.csdefのStartup Taskから起動されるように設定を行い発行してみたのですがデプロイに失敗(リサイクル中になる)してしまいます。
どうやら、インスタンスにAzure PowerShellがインストールされていないため、Set-AzureServiceAntimalwareExtensionが叩けなかったようです。
VS2012からの発行でAntimalwareを有効にする方法、もしくはAzure PowerShellをサイレントインストールする方法をご教示ください。
よろしくお願いいたします。
- 編集済み あたっくす 2015年4月24日 11:39
回答
-
こんにちは。
https://github.com/Azure/azure-powershell/releases
こちらのWindows StandaloneのリンクにMSIファイルがありますので、そちらを使えばサイレントインストールも可能かと思います。(一般的なMSIファイルのサイレントインストール方法で問題ないかと)
misファイルを事前にダウンロードするようにするか、あらかじめプロジェクトに含めたうえで
msiexec /i azure-powershell.msi /qn AGREETOLICENSE="yes"
などでインストールできると思います。(管理者権限で以前のバージョンなどがインストールされていない前提)
- 回答としてマーク あたっくす 2015年4月26日 9:27
すべての返信
-
こんにちは。
https://github.com/Azure/azure-powershell/releases
こちらのWindows StandaloneのリンクにMSIファイルがありますので、そちらを使えばサイレントインストールも可能かと思います。(一般的なMSIファイルのサイレントインストール方法で問題ないかと)
misファイルを事前にダウンロードするようにするか、あらかじめプロジェクトに含めたうえで
msiexec /i azure-powershell.msi /qn AGREETOLICENSE="yes"
などでインストールできると思います。(管理者権限で以前のバージョンなどがインストールされていない前提)
- 回答としてマーク あたっくす 2015年4月26日 9:27
-
だいぶ遅くなりましたがなんとかなりましたのでご報告です。
プロジェクトには以下のファイルを追加しておく必要があります。
・startup.cmd
・AntimalwareSetUp.ps1
・AntimalwareConfig.xml
・azure-powershell.0.8.16.msi
・Cert.pfx(証明書)
startup.cmd(Startup Taskに登録するファイル)
@echo off PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "StartupLog1.txt" 2>&1 PowerShell "msiexec /i Antimalware\azure-powershell.0.8.16.msi /qn AGREETOLICENSE='yes'" >> "StartupLog2.txt" 2>&1 PowerShell "Start-Sleep -s 60" >> "StartupLog3.txt" 2>&1 PowerShell .\AntimalwareSetUp.ps1 >> "StartupLog4.txt" 2>&1 EXIT /B %errorlevel%
AntimalwareSetUp.ps1
#証明書のインポート $pfxfile = "Cert.pfx" $pfxpassword = "『証明書のパスワード』" $certStore = "Cert:\CurrentUser\My" $secpass = ConvertTo-SecureString -String $pfxpassword -Force –AsPlainText Import-PfxCertificate -FilePath $pfxfile -Password $secpass -CertStoreLocation $certStore #証明書の取得 $certThumbprint = "『サムプリント』" $cert = Get-ChildItem Cert:\CurrentUser\My\$certThumbprint #Azureに接続 $subscriptionName = "『サブスクリプション名』" $subscriptionId = "『サブスクリプションID』" Set-AzureSubscription -SubscriptionName $subscriptionName -SubscriptionId $subscriptionId -Certificate $cert Select-AzureSubscription -SubscriptionName $subscriptionName $key = Get-AzureStorageKey -StorageAccountName 『ストレージアカウント名』 $storagecontext = New-AzureStorageContext -StorageAccountName 『ストレージアカウント名』 -StorageAccountKey $key.Primary $config = [xml](Get-Content "AntimalwareConfig.xml") Set-AzureServiceAntimalwareExtension -ServiceName 『クラウドサービス名』 -Slot Production -Role 『インスタンス名』 -StorageContext $storagecontext -AntimalwareConfiguration $config
以上です。