【Azure for IT Pro】Windows Azure Service Management コマンドレット がインストールできない場合の回避方法

※ここでご紹介する方法はマイクロソフトにより正式にサポートされてものではありませんのでご了承ください

Windows Azure のサブスクリプションは、Windows Azure ポータル以外に、Windows PowerShell からも操作できます。管理作業や展開作業を自動化したい!といった場合には、やはりスクリプトの出番です。スクリプトといえば  IT Pro の十八番ですよね!

ただしマイクロソフトのサイトで提供されているコマンドレットは、まだ Windows 7/2008R2 SP1 および Windows Azure SDK 1.4 に対応していません。そのため、既に Windows 7 SP1 Windows Azure SDK 1.4 をインストールしてしまった環境では インストール時に以下のメッセージが出て失敗しまします。

image
Operationg System Not Supported.PLease review your machine configuration and try again. Click Close to exit the Configuration Wizard.

この問題を回避して、ひとまず Cmdlet を使用可能にするには、インストール用のパッケージを少し修正する必要があります。

ということで、コマンドレットを使用するまでの準備手順を以下に記しておきます。

(01)SDK をインストールする

SDK がまだインストールされていない場合には、Windows Azure 用 PowerShell コマンドレットをインストールする前に、最新の Windows Azure SDK(2011年3月時点では V1.4)をインストールしておきましょう。

Download details: Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio (March 2011)

※日本語版はまだリリースされていませんので英語版をインストールしてください。

(02)Windows Azure Service Management コマンドレット をダウンロードする

Windows Azure Service Management コマンドレットは以下からダウンロードすることができますので、ダウンロードしておいてください。

Windows Azure Service Management CmdLets - Release: Service Management Cmdlets - Feb 2011 Update

(03)(02)でダウンロードしたファイルを実行して解凍

ダウンロードした WASMCmdlets.Setup.exe を実行して、ファイルを解凍します。

解凍が完了すると、以下のフォルダが作成されます。

C:\WASMCmdlets

(04)バージョンを修正してインストールコマンド(startHere.cmd )を実行する

C:\WASMCmdlets の直下には startHere.cmd というバッチファイルが格納されていますので、これを実行するとコマンドレットがインストールされます。

ただし、冒頭で述べたように、OSやSDKのバージョン不一致でエラーになることがあります。

その場合には、2つの対処を行います。

■OS バージョン不一致への対処

C:\WASMCmdlets\setup\dependency.dep ファイルをメモ帳で開いて以下のように赤字の部分を追記してみてください。

※保存後、拡張子が dep であることを確認してください

<?xml version="1.0" encoding="utf-8" ?> <DependencyCheckerConfiguration>   <title>WASM Cmdlets</title>   <image>resources\AzureServicesPlatformTools.png</image>   <previews>     <preview name="Check dependencies for Azure Management Tools"        description="Check dependencies for Azure Management Tools" />     <preview name="Install Windows Azure Management Tools PowerShell SnapIn"          description="Install Windows Azure Management Tools PowerShell SnapIn" />   </previews>   <tasks>     <task description="Install WASM PowerShell SnapIn"           scriptName=".\scripts\tasks\installPSSnapIn.cmd" displayConsole="true"/>   </tasks>   <dependencies>     <os type="Vista;Server" buildNumber="6001;6002;6000;6100;6200;7100;7600 ;7601">       <dependency       value=".\scripts\dependencies\check\CheckNET35SP1.ps1"       enabled="true"       optional="false"

(略)

”7601”とはもちろん、OS のビルド番号です。SP1が適用されると、7600 から 7601 にビルド番号がアップします。

■ Azure SDK バージョン不一致の対処

SDK のバージョン不一致が発生すると、以下のエラーが発生します。

image
Download and install the Windows Azure SDK 1.3

この場合には、現在インストールされている SDK のバージョンを、インストールするスクリプト内(C:\WASMCmdlets\setup\scripts\dependencies\check\CheckAzureSDK.ps1 )に記載します。

バージョンを調べるには、コントロールパネルを開いて、Windows Azure SDK のバージョンを確認します。

image

この場合に、Windows Azure SDK のバージョンは、1.4.20227.1419 です。よって、CheckAzureSDK.ps1 を以下のように修正します。

function SearchUninstall($SearchFor, $SearchVersion, $UninstallKey) { $uninstallObjects = ls -path $UninstallKey; $found = $FALSE;

foreach($uninstallEntry in  $uninstallObjects) {    $entryProperty = Get-ItemProperty -path registry::$uninstallEntry    if($entryProperty.DisplayName -like $searchFor)     {        if($entryProperty.DisplayVersion -eq $searchVersion)        {          $found = $TRUE;          break;        }     } }

$found; }

## $res1 = SearchUninstall -SearchFor 'Windows Azure SDK*' -SearchVersion '1.3.11122.0038' -UninstallKey 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\'; ## $res2 = SearchUninstall -SearchFor 'Windows Azure SDK*' -SearchVersion '1.3.11122.0038' -UninstallKey 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\';

$res1 = SearchUninstall -SearchFor 'Windows Azure SDK*' -SearchVersion '1.4.20227.1419' -UninstallKey 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\'; $res2 = SearchUninstall -SearchFor 'Windows Azure SDK*' -SearchVersion '1.4.20227.1419' -UninstallKey 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\';

($res1 -or $res2)

この状態でファイルを保存して再度実行してみましょう。

image

表示されているSDKのバージョンは違いますが、内部では SDK 1.4 環境下で処理されています。

[Next] をクリックすると最後に、C:\WASMCmdlets\setup\Scripts\tasks にある installPSSnapIn.cmd が実行されてインストールは完了です。

image

Windows PowerShell のコンソールを開いて、Windows Azure Service Management コマンドレットが読み込まれていることを確認してみましょう。

まずは、プロファイルにWindows Azure Service Management コマンドレットを読み込みます。

PS C:\> Add-PSSnapin AzureManagementToolsSnapIn

次に、コマンドレットの一覧を表示してみます。

PS C:\Users\junichia.FAREAST> Get-Command -PSSnapin AzureManagementToolsSnapIn

CommandType Name Definition ----------- ---- ---------- Cmdlet Add-Certificate Add-Certificate -ServiceName <String> -Certifica... Cmdlet Get-ActiveTransfers Get-ActiveTransfers -RoleName <String> [-Instanc... Cmdlet Get-AffinityGroup Get-AffinityGroup [-Name] <String> -Subscription... Cmdlet Get-AffinityGroups Get-AffinityGroups -SubscriptionId <String> -Cer... Cmdlet Get-Certificate Get-Certificate -ServiceName <String> -Thumbprin... Cmdlet Get-Certificates Get-Certificates [-ServiceName] <String> -Subscr... Cmdlet Get-CommonConfigurationLogs Get-CommonConfigurationLogs -RoleName <String> -... Cmdlet Get-Deployment Get-Deployment [-Slot] <String> -ServiceName <St... Cmdlet Get-DiagnosticAwareRoleInstances Get-DiagnosticAwareRoleInstances [-RoleName] <St... Cmdlet Get-DiagnosticAwareRoles Get-DiagnosticAwareRoles [-StorageAccountName <S... Cmdlet Get-DiagnosticConfiguration Get-DiagnosticConfiguration -BufferName <String>... Cmdlet Get-HostedProperties Get-HostedProperties [-ServiceName] <String> -Su... Cmdlet Get-HostedService Get-HostedService [-ServiceName] <String> -Subsc... Cmdlet Get-HostedServices Get-HostedServices -SubscriptionId <String> -Cer... Cmdlet Get-OperationStatus Get-OperationStatus [-OperationId] <String> [-Wa... Cmdlet Get-OSVersions Get-OSVersions -SubscriptionId <String> -Certifi... Cmdlet Get-StorageKeys Get-StorageKeys [-ServiceName] <String> -Subscri... Cmdlet Get-StorageProperties Get-StorageProperties [-ServiceName] <String> -S... Cmdlet Get-StorageServices Get-StorageServices -SubscriptionId <String> -Ce... Cmdlet Move-Deployment Move-Deployment [[-DeploymentNameInProduction] <... Cmdlet New-Deployment New-Deployment [-Slot] <String> [-Package] <Stri... Cmdlet New-StorageKey New-StorageKey [-KeyType] <String> -ServiceName ... Cmdlet Remove-Certificate Remove-Certificate -ServiceName <String> -Thumbp... Cmdlet Remove-Deployment Remove-Deployment [-Slot] <String> -ServiceName ... Cmdlet Set-CommonConfigurationLogs Set-CommonConfigurationLogs [-OverallQuotaInMB <... Cmdlet Set-Deployment Set-Deployment [[-ConfigurationScript] <ScriptBl... Cmdlet Set-DeploymentConfiguration Set-DeploymentConfiguration [[-ScriptConfigurati... Cmdlet Set-DeploymentStatus Set-DeploymentStatus [-Status] <String> [-Slot] ... Cmdlet Set-FileBasedLog Set-FileBasedLog [-DirectoriesConfiguration <Dir... Cmdlet Set-InfrastructureLog Set-InfrastructureLog [-LogLevelFilter <LogLevel... Cmdlet Set-PerformanceCounter Set-PerformanceCounter [-PerformanceCounters <Pe... Cmdlet Set-WalkUpgradeDomain Set-WalkUpgradeDomain [-DomainNumber] <Int32> [-... Cmdlet Set-WindowsAzureLog Set-WindowsAzureLog [-LogLevelFilter <LogLevel>]... Cmdlet Set-WindowsEventLog Set-WindowsEventLog [-EventLogs <String[]>] [-Lo... Cmdlet Start-OnDemandTransfer Start-OnDemandTransfer -DataBufferName <String> ... Cmdlet Stop-ActiveTransfer Stop-ActiveTransfer -RoleName <String> [-Instanc...

コマンドレットの一覧が出てくればひとまずOKです。