• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Windows Azure Drive
 

Windows Azure Drive

on

  • 803 views

Работа с Windows Azure Drive

Работа с Windows Azure Drive

Statistics

Views

Total Views
803
Views on SlideShare
700
Embed Views
103

Actions

Likes
0
Downloads
2
Comments
0

2 Embeds 103

https://kb.epam.com 81
https://jira.epam.com 22

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Windows Azure Drive Windows Azure Drive Presentation Transcript

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