Your SlideShare is downloading. ×
0
Работа сWindows Azure Drive                                25/07/2012                            Ревенков Павел     EPAM C...
Data Management Services• SQL Azure – реляционная база данных;• Tables – не реляционные таблицы;• Queue - очереди;• Blob -...
Пример: CMS-системаPublishers                                                    Author        Instance 1   Instance 2    ...
Windows Azure Drive   AzureSubscription   Storage Account       (100 ТВ)                     Container                    ...
Загрузка данных в Blob Storagevar storageAccount = CloudStorageAccount.Parse(    ConfigurationManager        .ConnectionSt...
1. public static void UploadVHDFile(string filePath, string containerName, string blobName)2. {3.       const int partSize...
Режимы работы Azure Drive             CloudDrive                                                Snapshot                cl...
Работа с Windows Azure Drivevar account = CloudStorageAccount.Parse(    RoleEnvironment.GetConfigurationSettingValue("Conn...
1. public ActionResult Index()2. {3.       var account = CloudStorageAccount.Parse(4.           RoleEnvironment.GetConfigu...
Questions?             10
Ссылки и материалыDifferences Between the Storage Emulator andWindows Azure Storage Services:     http://msdn.microsoft.co...
Upcoming SlideShare
Loading in...5
×

Windows Azure Drive

591

Published on

Работа с 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
591
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Windows Azure Drive"

  1. 1. Работа сWindows Azure Drive 25/07/2012 Ревенков Павел EPAM Cloud Computing Competence Center pavlo_revenkov@epam.com
  2. 2. Data Management Services• SQL Azure – реляционная база данных;• Tables – не реляционные таблицы;• Queue - очереди;• Blob - двоичные данные;• Drive - подключаемые облачные NTFS-тома (VHD). 2
  3. 3. Пример: CMS-системаPublishers Author Instance 1 Instance 2 Instance 3 Instance 4 Mount 30 minutes Snapshot Repository 3
  4. 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. 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. 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. 7. Режимы работы Azure Drive CloudDrive Snapshot client URL Exception Mount Mount ДаAuthor Lease режим Snapshot режим Publisher чтение чтение запись Windows Azure Drive 7
  8. 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. 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. 10. Questions? 10
  11. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×