Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building Applications with Windows Azure Storage Brad Calder Director/Architect Microsoft Corporation.

Similar presentations


Presentation on theme: "Building Applications with Windows Azure Storage Brad Calder Director/Architect Microsoft Corporation."— Presentation transcript:

1 Building Applications with Windows Azure Storage Brad Calder Director/Architect Microsoft Corporation

2

3

4

5 BlobContainerAccount cohowinery images PIC01.JPG PIC02.JPG videos VID1.AVI http://.blob.core.windows.net/ /

6

7 StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey(accountName, key); string baseUri = string.Format("http://{0}.blob.core.windows.net", accountName); CloudBlobClient blobClient = new CloudBlobClient(baseUri, credentials); // Create Container CloudBlobContainer cloudContainer = blobClient.GetContainerReference(containerName); bool hasCreated = cloudContainer.CreateIfNotExist(); // Access Blob in the Container CloudBlob cloudBlob = cloudContainer.GetBlobReference(blobName); //BlobRequestOptions has retry policy, timeout etc. BlobRequestOptions options = new BlobRequestOptions(); //Upload the local file to Blob service cloudBlob.UploadFile(uploadFileName, options); //Download to local file name cloudBlob.DownloadToFile(downloadFileName, options);

8

9

10

11

12

13

14 Windows Azure Blob Service Application Lease Drive X:

15 Windows Azure Drive Demo

16 Windows Azure

17 CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("CloudStorageAccount"); //Initialize the local cache for drives mounted by this role instance CloudDrive.InitializeCache(localCacheDir, cacheSizeInMB); //Create a cloud drive (PageBlob) CloudDrive drive = account.CreateCloudDrive(pageBlobUri); drive.Create(1000 /* sizeInMB */); //Mount the network attached drive on the local file system string pathOnLocalFS = drive.Mount(cacheSizeInMB, DriveMountOptions.None); //Use NTFS APIs to Read/Write files to drive … //Snapshot drive while mounted to create backups Uri snapshotUri = drive.Snapshot(); //Unmount the drive drive.Unmount();

18

19

20

21 EntityTableAccount cohowinery customers Name =… Email = … Name =… Email = … winephotos Photo ID =… Date =… Photo ID =… Date =…

22

23

24

25 PartitionKey (Category) RowKey (Title) TimestampReleaseDate Action Fast & Furious…2009 Action The Bourne Ultimatum…2007 … ……… Animation Open Season 2…2009 Animation The Ant Bully…2006 PartitionKey (Category) RowKey (Title) TimestampReleaseDate Comedy Office Space…1999 … ……… SciFi X-Men Origins: Wolverine …2009 … ……… War Defiance…2008 PartitionKey (Category) RowKey (Title) TimestampReleaseDate Action Fast & Furious…2009 Action The Bourne Ultimatum…2007 … ……… Animation Open Season 2…2009 Animation The Ant Bully…2006 Comedy Office Space…1999 … ……… SciFi X-Men Origins: Wolverine …2009 … ……… War Defiance…2008

26

27 [DataServiceKey("PartitionKey", "RowKey")] public class Movie { /// Movie Category is the partition key public string PartitionKey { get; set; } /// Movie Title is the row key public string RowKey { get; set; } public DateTime Timestamp { get; set; } public int ReleaseYear { get; set; } public double Rating { get; set; } public string Language { get; set; } public bool Favorite { get; set; } }

28 string baseUri = string.Format("http://{0}.table.core.windows.net", accountName); CloudTableClient tableClient = new CloudTableClient(baseUri, credentials); // Create Movie Table string tableName = “Movies“; tableClient.CreateTableIfNotExist(tableName); TableServiceContext context = tableClient.GetDataServiceContext(); // Add movie context.AddObject(tableName, new Movie("Action", “White Water Rapids Survival")); context.SaveChangesWithRetries(); // Query movie var q = (from movie in context.CreateQuery (tableName) where movie.PartitionKey == "Action" && movie.Rating > 4.0 select movie).AsTableServiceQuery (); foreach (Movie movieToUpdate in q) { movieToUpdate.Favorite = true; context.UpdateObject(movieToUpdate); } context.SaveChangesWithRetries( ); SaveChangesOptions.Batch

29

30

31 MessageQueueAccount order processing customer ID order ID http://… cohowinery

32 Azure Queue Input Queue (Work Items)

33 Azure Queue Input Queue (Work Items)

34 string baseUri = string.Format("http://{0}.queue.core.windows.net", accountName); CloudQueueClient queueClient = new CloudQueueClient(baseUri, credentials); //Create Queue CloudQueue queue = queueClient.GetQueueReference(queueName); queue.CreateIfNotExist(); //Add Message CloudQueueMessage message = new CloudQueueMessage(“some content"); queue.AddMessage(message); //Get Message message = queue.GetMessage(TimeSpan.FromMinutes(3) /*Invisibility timeout*/); // Process Message within the Invisibility Timeout //Delete Message queue.DeleteMessage(message);

35

36

37

38


Download ppt "Building Applications with Windows Azure Storage Brad Calder Director/Architect Microsoft Corporation."

Similar presentations


Ads by Google