Your SlideShare is downloading. ×
Windows Azure Drive
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Windows Azure Drive

566
views

Published on

Работа с Windows Azure Drive

Работа с Windows Azure Drive


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
566
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Работа сWindows Azure Drive 25/07/2012 Ревенков Павел EPAM Cloud Computing Competence Center pavlo_revenkov@epam.com
  • 2. Data Management Services• SQL Azure – реляционная база данных;• Tables – не реляционные таблицы;• Queue - очереди;• Blob - двоичные данные;• Drive - подключаемые облачные NTFS-тома (VHD). 2
  • 3. Пример: CMS-системаPublishers Author Instance 1 Instance 2 Instance 3 Instance 4 Mount 30 minutes Snapshot Repository 3
  • 4. Windows Azure Drive AzureSubscription Storage Account (100 ТВ) Container Block Blob (200 GB) Storage Account (100 ТВ) Container Page Blob (1 ТВ) Storage Account Container … (100 ТВ) Azure Drive (1 ТВ) Storage Account (100 ТВ) … Storage Account (100 ТВ) 4
  • 5. Загрузка данных в Blob Storagevar storageAccount = CloudStorageAccount.Parse( ConfigurationManager .ConnectionStrings[ConnectionStringSetting] .ConnectionString);var blobClient = storageAccount.CreateCloudBlobClient();var container = blobClient.GetContainerReference(containerName);var pageBlob = container.GetPageBlobReference(blobName);using (var fileStream = new FileStream(filePath, FileMode.Open)) { pageBlob.Create(fileStream.Length); var buffer = new byte[partSize]; while (offset < fileStream.Length) { var bytesRead = fileStream.Read(buffer, 0, partSize); pageBlob.WritePages(new MemoryStream(buffer, 0, bytesRead), offset); offset += bytesRead; }} 5
  • 6. 1. public static void UploadVHDFile(string filePath, string containerName, string blobName)2. {3. const int partSize = 1024 * 1024;4.5. var storageAccount = CloudStorageAccount.Parse(6. ConfigurationManager.ConnectionStrings[ConnectionStringSetting].ConnectionString);7.8. var blobClient = storageAccount.CreateCloudBlobClient();9. var container = blobClient.GetContainerReference(containerName);10. container.CreateIfNotExist();11.12. var pageBlob = container.GetPageBlobReference(blobName);13. pageBlob.DeleteIfExists();14. pageBlob.Properties.ContentType = "binary/octet-stream";15.16. using (var fileStream = new FileStream(filePath, FileMode.Open))17. {18. int offset = 0;19.20. pageBlob.Create(fileStream.Length);21.22. var buffer = new byte[partSize];23. while (offset < fileStream.Length)24. {25. var bytesRead = fileStream.Read(buffer, 0, partSize);26.27. pageBlob.WritePages(new MemoryStream(buffer, 0, bytesRead), offset);28.29. offset += bytesRead;30.31. Console.Write(.);32. }33. }34. } 6
  • 7. Режимы работы Azure Drive CloudDrive Snapshot client URL Exception Mount Mount ДаAuthor Lease режим Snapshot режим Publisher чтение чтение запись Windows Azure Drive 7
  • 8. Работа с Windows Azure Drivevar account = CloudStorageAccount.Parse( RoleEnvironment.GetConfigurationSettingValue("ConnectionString"));var drive = account.CreateCloudDrive("drives/vhd");try{ drive.Mount(0, DriveMountOptions.None); ...}catch (CloudDriveException e){ drive = account.CreateCloudDrive(drive.Snapshot().AbsoluteUri); drive.Mount(0, DriveMountOptions.None);}finally{ drive.Unmount();} 8
  • 9. 1. public ActionResult Index()2. {3. var account = CloudStorageAccount.Parse(4. RoleEnvironment.GetConfigurationSettingValue("ConnectionString"));5.6. var drive = account.CreateCloudDrive("drives/vhd");7. var letter = string.Empty;8.9. FileInfo[] files;10. try11. {12. letter = drive.Mount(0, DriveMountOptions.None);13. }14. catch (CloudDriveException e)15. {16. drive = account.CreateCloudDrive(drive.Snapshot().AbsoluteUri);17. letter = drive.Mount(0, DriveMountOptions.None);18. }19. finally20. {21. files = new DirectoryInfo(drive.LocalPath).GetFiles();22. drive.Unmount();23. }24. ViewBag.Message = String.Format("Azure Drive mounted on: {0}", letter);25.26. return View(files);27. } 9
  • 10. Questions? 10
  • 11. Ссылки и материалыDifferences Between the Storage Emulator andWindows Azure Storage Services: http://msdn.microsoft.com/en-us/gg433135Windows Azure Drive whitepaper: http://go.microsoft.com/?linkid=9710117 11