Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Azure Tables In this module- Learn how to store data in tables

Similar presentations


Presentation on theme: "Using Azure Tables In this module- Learn how to store data in tables"— Presentation transcript:

1 Using Azure Tables In this module- Learn how to store data in tables
Create and destroy data How tables scale

2 What is the Table Service?
Simple Highly scalable Cost effective Non-relational Hierarchical

3 Storage Account: MovieData
Table Structure Account Table Storage Account: MovieData Star Wars Matrix Fan Boys Table Name: Movies Mike Collier Mr. Anderson Bill Gates Table Name: Customers Entity Tables store entities. Entity schema can vary in the same table.

4 Is not relational Can Not-
Create foreign key relationships between tables. Perform server side joins between tables. Create custom indexes on the tables. No server side Count(), for example.

5 Required Properties All entities must have the following properties:
Timestamp PartitionKey RowKey

6 Sample Table Kirk NC1701 6855 Kobayashi Maru Drive $35,490.00 NC1701A
Partition Key Row Key DeliveryAddress OrderAmount Kirk NC1701 6855 Kobayashi Maru Drive $35,490.00 NC1701A 409 Tiberious Road $98.99 NC1701B 1024 Priceline Ave $4,523,765,102.99 Archer 31415 999 Sliders Blvd $5,780.99 1 1405 Suliban Road $55.39 234 DS9, Level 29, Suite 782 $1.58 Bender 900 South Futurama Drive $87,399.99 VIN 12345 KJUDH Quantum Leap != Sliders

7 WCF Data Services Creates and consumes data via OData (REST-based API's) The Table Service REST API implements the WCF Data Services API. Some features are extended. What WCF Data Service features are not support? Extended?

8 Creating a Table Tables can be created and destroyed in code.
Wire up your storage in the on_start method. Use a CloudTableClient to access the table.

9 An Entity in C# This is how we represent an entity in normal .NET code. It is a very common practice.

10 Inherit or add the Required Fields
By inheriting from TableServiceEntity we can easily store our entity in an Azure Table.

11 Create a Context Class WCF Data Services needs a context class.
CloudTableClient.CreateTablesFromModel() – Uses property with IQueryable<T> in class derived from TableServiceContext. “movies” – entity set which DataServiceContext is tracking.% WCF Data Services needs a context class. This represents your connection to the table.

12 Adding an Entity Other operations are just like normal WCF Data Services, such as delete, update, etc.

13 Deleting an Entity Keep the entity, or use a lightweight copy for better performance.

14 Batching Use batching to increase performance Unit of Work pattern

15 Queries Queries less than 5 seconds return the results.
Queries between 5 and 30 seconds return a continuation token so you can fetch pages of results. Queries over 30 seconds are cancelled. When more than 1,000 entities are found, a continuation token is returned.

16 Entity Group Transactions
Transactions are supported for entities in the same table and partition using a batch. Limited to up to 100 entities per batch. There may be only one operation per entity in the batch. Can use BeginSaveChanges and EndSaveChanges for async operations.

17 Partition Key and Row Keys matter!
Performance Super Fast Unique Partition Key Very Fast Partition Key + Row Key Slower Only Partition Key No Row Key Slowest No Partition Key Partition Key and Row Keys matter!

18 Guidance Treat entity schema as a data contract.
Manage schema version as an entity property. Consider self configuration and setup during startup. Use tables as a cache of relational data.

19 Guidance Partitions are Auto-Balanced Hot partitions may be scaled up
No need to partition into equal bins Hot partitions may be scaled up Windows Azure fabric may dedicate more resources to partitions with high Tx load Partition Key AND Row Key = Unique ID Must include PartitionKey for Create,Update,Delete Select queries across partitions run sequentially Don’t use sequential partition keys Slide Objective Discusses horizontal partitioning in Windows Azure Table storage Speaking notes Table storage supports partitioning out of the box. It is a key to scalability of table storage The storage fabric can then load balance your partitions and potentially move ‘hot’ partitions to a dedicated node There is no need to partition data into equal sized partitions Rather just partition as aggressively as your application will permit- remembering that your scope of a transaction (and ideally of any query) is a single partition Create Read and Update operations always act within the scope of a partition and need the partition key. This means if you want to delete entities from a table without the partition key you’ll have to iterate over all the partitions yourself Select queries across partitions run sequentially- you’ll receive the data off each partition in sequence; Notes Queue storage is partitioned by Queue name Blob storage is partitioned by Bob name (i.e. partition size of 1)

20 Guidance Continuation Tokens May Be Returned from Cross Partition Queries Any query not including the Rowkey and PartitionKey (only those as well) needs to handle Continuation tokens Key Columns Up to 1KB in size Should aim to keep to 260 char URI limit Be aggressive e.g. Only ever query by an ID? Use Unique partition key and RowKey = ‘ ‘ for a partition of 1 Slide Objective More detail that Discusses horizontal partitioning in Windows Azure Table storage Speaking notes Understanding the sequential nature of cross partition queries is important Continuation tokens may be returned at any time (i.e. data comes back in multiple pages) You will always get a continuation token if you cross a hardware boundary- i.e. you move between partitions that sit on different nodes The Storage API handles continuation tokens elegantly, but, it may mask a poor architecture- YOU DO NOT WANT TO RUN A QUERY THAT CROSSES HUNDRED OF SERVERS! Be aggressive with partitioning- if you’ll only ever query something by a single key use an empty Row key and a unique partition key for a partition of 1. Can also just use blob storage which is already partitioned by Blob name Notes Queue storage is partitioned by Queue name Blob storage is partitioned by Bob name (i.e. partition size of 1) Good article from Julie Lerman. Worth reading when discussing table storage

21 Costs Storage = $0.15 / GB stored / month
Storage transactions = $0.01 / 10K Data transfers = $0.10 in / $0.15 out / GB - ($0.30 in / $0.45 out / GB in Asia)*

22 Windows Azure Guest Book Using Tables
C:\WindowsAzurePlatformKit\Demos\WindowsAzureGuestBookUsingTables demo

23 Q & A ponderances?

24 Exploring Windows Azure Storage
C:\WAPTK\Labs\ExploringWindowsAzureStorageVS2010 Do Exercise 1. C:\WindowsAzurePlatformKit\Labs\ExploringWindowsAzureStorage hands on lab time


Download ppt "Using Azure Tables In this module- Learn how to store data in tables"

Similar presentations


Ads by Google