Azure SDK 1.3 がリリースされた影響で、 PowerShellのAzure Management Tools Cmdlets がインストールできないなど色々と問題が出ています。
Azure SDK 1.2 の頃から利用している人は、Azure SDK 1.3 でアップグレードインストールした段階で、.NETのアセンブリリダイレクトを設定すればよいのですが、全く新しい環境に Azure Management Tools Cmdlets をインストールする場合は、インストール時にビルドエラーが発生してインストールに失敗してしまします。
Azure SDK 1.3 に対応させるアセンブリリダイレクトの設定について
http://sqlazure.jp/b/?p=368
ここでは、Azure SDK 1.3 しかインストールされていない状態で、Azure Management Tools Cmdlets をインストールする方法を紹介します。この方法で新しい環境に Azure Management Tools Cmdlets をインストールすることが可能になります。
Azure Management Tools Cmdletsの使用するインストールファイルは、以下の AzureServiceManagementCmdlets.Setup.20100226 になります。(Azure SDK 1.3 に対応しているものが出た場合は、この作業を行わなくてもよいでしょう)
Azure Management Tools Cmdlets
http://code.msdn.microsoft.com/azurecmdlets
では、インストールしてみましょう。
1.プロジェクトファイルの書き換え
ダウンロードした AzureServiceManagementCmdlets.Setup.20100226.exe を実行すると、 C:\AzureServiceManagementCmdlets フォルダにファイルが展開されます。このフォルダ内の startHere.cmd を実行してインストールを行うわけですが、実行する前に以下のファイルをメモ帳などで編集します。
C:\AzureServiceManagementCmdlets\code\AzureManagementTools.Cmdlets\AzureManagementTools.Cmdlets.csproj
編集場所はXMLで記述されている Projectエレメント内、ItemGroupエレメント内、Reference エレメントです。このReferenceエレメントのInclude アトリビュートに Microsoft.WindowsAzure.StorageClient が含まれる物を探してVersionを1.0.0.0から1.1.0.0に変更します。
以下の一行の変更するだけです。
<reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
変更後の AzureManagementTools.Cmdlets.csproj は以下のようになります。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CD5AA507-F5EF-473D-855B-84B91A1ABE54}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Samples.AzureManagementTools.PowerShell</RootNamespace>
<AssemblyName>Microsoft.Samples.AzureManagementTools.PowerShell</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.ServiceModel">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.ServiceModel.Web">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AffinityGroups\GetAffinityGroup.cs" />
<Compile Include="AffinityGroups\GetAffinityGroups.cs" />
<Compile Include="AzureManagementToolsSnapIn.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Certificates\AddCertificate.cs" />
<Compile Include="Certificates\RemoveCertificate.cs" />
<Compile Include="Certificates\GetCertificate.cs" />
<Compile Include="Certificates\GetCertificates.cs" />
<Compile Include="CmdletBase.cs" />
<Compile Include="ConfigurationConstants.cs" />
<Compile Include="Diagnostics\GetActiveTransfers.cs" />
<Compile Include="Diagnostics\GetCommonConfigurationLogs.cs" />
<Compile Include="Diagnostics\SetCommonConfigurationLogs.cs" />
<Compile Include="Diagnostics\StopActiveTransfer.cs" />
<Compile Include="Diagnostics\GetDiagnosticConfiguration.cs" />
<Compile Include="Diagnostics\SetPerformanceCounter.cs" />
<Compile Include="Diagnostics\SetWindowsEventLog.cs" />
<Compile Include="Diagnostics\SetInfrastructureLog.cs" />
<Compile Include="Diagnostics\SetFileBasedLog.cs" />
<Compile Include="Diagnostics\InstrumentationCmdletBase.cs" />
<Compile Include="Diagnostics\SetWindowsAzureLog.cs" />
<Compile Include="Diagnostics\GetDiagnosticAwareRoleInstances.cs" />
<Compile Include="Diagnostics\DiagnosticsCmdletBase.cs" />
<Compile Include="Diagnostics\GetDiagnosticAwareRoles.cs" />
<Compile Include="Diagnostics\StartOnDemandTransfer.cs" />
<Compile Include="Helpers\AzureBlob.cs" />
<Compile Include="Helpers\CmdletExtensions.cs" />
<Compile Include="HostedServices\GetHostedService.cs" />
<Compile Include="Model\CertificateConfiguration.cs" />
<Compile Include="Model\CertificateContext.cs" />
<Compile Include="Model\DeploymentInfoContext.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Helpers\Utility.cs" />
<Compile Include="HostedServices\NewDeployment.cs" />
<Compile Include="HostedServices\RemoveDeployment.cs" />
<Compile Include="HostedServices\GetDeployment.cs" />
<Compile Include="HostedServices\GetHostedProperties.cs" />
<Compile Include="HostedServices\GetHostedServices.cs" />
<Compile Include="Common\GetOperationStatus.cs" />
<Compile Include="HostedServices\MoveDeployment.cs" />
<Compile Include="HostedServices\SetDeploymentConfiguration.cs" />
<Compile Include="HostedServices\SetDeploymentStatus.cs" />
<Compile Include="HostedServices\SetDeployment.cs" />
<Compile Include="HostedServices\SetWalkUpgradeDomain.cs" />
<Compile Include="Model\ManagementOperationContext.cs" />
<Compile Include="Model\HostedServiceContext.cs" />
<Compile Include="Model\RoleConfiguration.cs" />
<Compile Include="Model\RoleInstance.cs" />
<Compile Include="StorageServices\GetStorageKeys.cs" />
<Compile Include="StorageServices\GetStorageProperties.cs" />
<Compile Include="StorageServices\GetStorageServices.cs" />
<Compile Include="StorageServices\NewStorageKey.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Model\ClassDiagram.cd" />
</ItemGroup>
<ItemGroup>
<Content Include="Microsoft.Samples.AzureManagementTools.PowerShell.dll-Help.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Samples.WindowsAzure.ServiceManagement\Microsoft.Samples.WindowsAzure.ServiceManagement.csproj">
<Project>{A3BB648E-9C6D-4251-B0E1-6E05024AB71E}</Project>
<Name>Microsoft.Samples.WindowsAzure.ServiceManagement</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
2. startHere.cmdの実行
startHere.cmdを実行してインストールします。
3. AzureServiceManagementCmdletsの確認
PowerShellを実行して下記のコマンドを実行します。
PS C:\Users\kentaro> Add-PSSnapin AzureManagementToolsSnapIn
PS C:\Users\kentaro> Get-Command -PSSnapIn AzureManagementToolsSnapIn
下記のような結果が返ってくればAzureServiceManagementCmdletsがインストールされていることが確認できます。
次は、C#から、AzureServiceManagementCmdlets を操作する方法を紹介できればと思います。