Windows Azure SDK 1.1 February がリリース!! - waりとnaはてな日記
Using the Windows Azure Storage Services の Windows Azure Drives white paper.Windows Azure Drives white paper.
を参考に少し試してみました。がエラーが出て動かない…。
とりあえず、晒してみる。
.csdef
<?xml version="1.0" encoding="utf-8"?> <ServiceDefinition name="CloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> <WebRole name="WebRole1"> <InputEndpoints> <InputEndpoint name="HttpIn" protocol="http" port="80" /> </InputEndpoints> <LocalResources> <LocalStorage name="MyAzureDriveCache" cleanOnRoleRecycle="false" sizeInMB="100" /> </LocalResources> <ConfigurationSettings> <Setting name="DiagnosticsConnectionString" /> <Setting name="DataConnectionString" /> </ConfigurationSettings> </WebRole> </ServiceDefinition>.cscfg OSVersion の指定は、Windows Azure Guest OS Releases and SDK Compatibility Matrix を参考に。
<?xml version="1.0"?> <ServiceConfiguration serviceName="CloudService1" osVersion="WA-GUEST-OS-1.1_201001-01" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration"> <Role name="WebRole1"> <Instances count="1" /> <ConfigurationSettings> <Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" /> <Setting name="DataConnectionString" value="UseDevelopmentStorage=true" /> </ConfigurationSettings> </Role> </ServiceConfiguration>メソッド一部抜粋
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient(); CloudBlobContainer blobContainer = blobStorage.GetContainerReference("testpageblob"); blobContainer.CreateIfNotExist(); StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey("devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="); try { int driveSize = 50; int cacheSize = 50; Uri blobUri = new Uri("http://127.0.0.1:10000/container/testpageblob"); LocalResource localCache = RoleEnvironment.GetLocalResource("MyAzureDriveCache"); CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes); // これが無いと ERROR_NOT_INITIALIZED と怒られる。 CloudDrive drive = new CloudDrive(blobUri, credentials); drive.Create(driveSize); string driveLetter = drive.Mount(cacheSize, DriveMountOptions.None); } catch (CloudDriveException ex) { Debug.WriteLine(ex.StackTrace); throw; }
これで、drive.Create(driveSize); の箇所で "ERROR_PARAMETER_INVALID parameter 0)" と怒られる。
サイズが小さすぎるのかな?最小16って書いてたから大丈夫だと思うんだけど。
CloudDrive.Create Method (Microsoft.WindowsAzure.StorageClient)
試してみてわかったこと。
CloudDrive.InitializeCache を呼ばないと ERROR_NOT_INITIALIZED と怒られる。
ってか Azure 久しぶり過ぎてだいぶ忘れてる!!そもそも PageBlob とかどうするんだっけ?そこから間違えてる?