2010-02-03
Windows Azure SDK 1.1 February がリリース!!
C#, Windows Azure | |
![]()
どうも、最近すっかり更新が滞っていた割と普通です。某所で記事書かせて頂いたり、某所でセッションしたり、某所でライトニングトークしたり、冬コミで原稿描いたりと大忙しでした。今回は久々にバージョンアップしたWindows Azure SDK 1.1について紹介します。
Windows Azure SDK 1.1の概要
2009年11月13日から更新が止まっていたWindows Azure SDKのバージョン1.1がリリースされました。詳細なSDKの更新内容は、別途「Windows Azure SDK 1.1 参考サイト」を参照して頂くとして、主な更新内容は以下の二つだと思われます。
- Windows Azure Guest OSのバージョン管理
- Windows Azure Drives機能のリリース
また、今回のリリースで、Azure SDKを利用した開発を行うVisual Studioのバージョンがエライ事になっています。
- Visual Studio 2008 SP1
- Visual Studio 2010 RC(英語版はリリース済み!!)
Windows Azure SDK 1.1のインストール
「Windows Azure SDK 1.1 参考サイト」から、最新版 Windows Azure SDKのインストーラをダウンロードして「VSCloudService.exe」を実行して下さい。インストーラに従えばインストール出来るハズですが、Visual Studio 2010 beta2以下をインストールしている場合、以下の警告がでます。
「Windows Azure SDKをインストールしようとしてるけど、おめーの環境のVisual Studioが古いからインストールできないかも。Visual Stuido 2010RC以降が必要だぜ?」と言われています。Visual Studio 2010 Beta2をインストールしている際に、そのままインストールを続行しましたが問題なくインストールできました。
新機能1「Windows Azure Guest OSのバージョン管理」
実行するWindows Azure Guest OS(以下、単にGuest OS)のバージョンを指定できるようになりました。「ServiceConfiguration.cscfgファイル−<ServiceConfiguration>タグ−osVersion属性」で、Guest OSを設定します*1。「ServiceConfiguration.cscfgファイル」の設定例を以下に記述します。
<ServiceConfiguration serviceName="HelloAzureService" osVersion="WA-GUEST-OS-1.1_201001-01"> <Role name="WebRole1"> <Instances count="1" /> <ConfigurationSettings> <Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" /> </ConfigurationSettings> </Role> </ServiceConfiguration>
設定ファイルで指定できるGuest OSのバージョンはWindows Azure SDKのバージョンによって異なります*2。
- Windows Azure SDK version 1.0 (November 2009)で指定できるGuest OS
- Windows Azure Guest OS 1.0 (Release 200912-01) ⇒ 「osVersion="WA-GUEST-OS-1.0_200912-01"」と設定する
- Windows Azure Guest OS 1.1 (Release 201001-01) ⇒ 「osVersion="WA-GUEST-OS-1.1_201001-01"」と設定する
- Windows Azure SDK version 1.1 (February 2010)で指定できるGuest OS
- Windows Azure Guest OS 1.1 (Release 201001-01) ⇒ 「osVersion="WA-GUEST-OS-1.1_201001-01"」と設定する
ServiceConfiguration.cscfg内でosVersionの指定をしなかった場合、デフォルトバージョンを利用する旨の記述が存在しますが、デフォルトバージョンは定義されていないようです(以下はMSDNから抜粋)。
If you do not specify an OS version, Windows Azure will deploy your service to the default version; the default version is undefined.
また、「C:\Program Files\Windows Azure SDK\v1.1\schemas\ServiceConfigurationSchema.xsd」にServiceConfiguration.cscfgファイルのxsdファイルが格納されていますので、参照して頂くと理解が深まると思います。
新機能2「Windows Azure Drives機能」
Windows Azure上で実行されるロール(Webロール or Workerロール)からアクセスできるNTFSファイルシステムとして振舞う機能で、Page Blobを用いて実現されています。
MSDNから入手できるWindows Azure Drivesのwhite paperで記述されていますが、「Guest OS1.1」以降で使用できる機能です。
Windows Azure SDK 1.1のプロジェクトテンプレートでは「Microsoft.WindowsAzure.CloudDrive.dll」アセンブリが参照されていないため、Windows Azure Drivesの機能を利用する際には当該アセンブリを参照する必要があります。
「Microsoft.WindowsAzure.CloudDrive.dll」アセンブリの中身を「Visual Studioのオブジェクトブラウザ」で参照したところ、以下のクラスと列挙型が定義されていました。メソッドのシグネチャを確認したところ、Windows Azure Drivesの機能を利用するには「CloudDrive」クラスに注目していれば大丈夫そうです。
- Microsoft.WindowsAzure.StorageClient.CloudDrive(クラス)
- Microsoft.WindowsAzure.StorageClient.CloudDriveException(クラス)
- Microsoft.WindowsAzure.StorageClient.DriveMountOptions(列挙型)
さて、例によってコンパイルを通しただけのコード例ですが、実装イメージがつくと思いますので記述いたします。
StorageCredentialsAccountAndKey credentials =
new StorageCredentialsAccountAndKey("アカウント名", "アカウントのキー");
try
{
int driveSize = 20000;
int cacheSize = 20000;
Uri blobUri =
new Uri("ここでBlobのURIを指定する。PageBlobを使用しているなぁとしみじみ");
CloudDrive drive = new CloudDrive(blobUri, credentials);
drive.Create(driveSize);
string driveLetter = drive.Mount(cacheSize, DriveMountOptions.None);
}
catch (CloudDriveException ex)
{
Debug.WriteLine(ex.StackTrace);
throw ex;
}
直にPageBlobのURIを指定してWindows Azure Drivesを生成するようです。まだまだ機能の扱い方は分かっていませんが、追って解説したいと思います。
Windows Azure SDK 1.1 参考サイト
- What’s New In the Windows Azure SDK(MSDN)
- 今回紹介した「主な更新内容」が詳細に記述されています。
- Windows Azure Tools for Microsoft Visual Studio 1.1 (February 2010)
- Windows Azure SDK 1.1がダウンロードできます。
*1:ServiceConfiguration.cscfgの記述はService Configuration SchemaのMSDNを参照して下さい
*2:Windows Azure SDKのバージョン毎に指定出来るGuest OSはWindows Azure Guest OS Versions and SDK Compatibility Matrixを参照してください
- 27 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4GGLL_jaUS354US354&q=Windows+Azure+SDK+1.1
- 22 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&hs=UHD&newwindow=1&q=C#+private+&btnG=検索&lr=lang_ja&aq=f&oq=
- 20 http://twitter.com/
- 17 http://twitter.com/normalian
- 13 http://blogs.bitlan.net/ito/?p=74
- 12 http://bit.ly/9upkIT
- 8 http://www.google.com/search?hl=ja&lr=lang_ja&ie=UTF-8&oe=UTF-8&q=c#+ランダム+文字列&num=50
- 7 http://longurl.org
- 7 http://www.google.co.jp/search?hl=ja&source=hp&q=app.config+取得&lr=&aq=0&oq=app.config
- 6 http://bit.ly/9FpIrh


