Presentation is loading. Please wait.

Presentation is loading. Please wait.

Azure in a Day Azure Tables Module 1: Azure Tables Overview Module 2: REST API – DEMO: Azure Table REST API Module 3: Querying Azure Tables – DEMO: Querying.

Similar presentations


Presentation on theme: "Azure in a Day Azure Tables Module 1: Azure Tables Overview Module 2: REST API – DEMO: Azure Table REST API Module 3: Querying Azure Tables – DEMO: Querying."— Presentation transcript:

1

2 Azure in a Day Azure Tables Module 1: Azure Tables Overview Module 2: REST API – DEMO: Azure Table REST API Module 3: Querying Azure Tables – DEMO: Querying Azure Tables – DEMO: Paging with Azure Tables Module 4: Insert, Updating, Deleting – DEMO: Inserting – DEMO: Updating – DEMO: Deleting Module 5: Concurrency and Entity Group Transactions – DEMO: Concurrency – DEMO: Entity Group Transactions

3 DEMO What we will be building

4 Agenda I.Overview II.API Overview – REST API III.StorageClient API A.Querying B.Inserting C.Updating D.Deleting IV.Concurrency V.Entity Group Transactions

5 Azure Table Storage “I don’t think that means what you think it means” - Fezzik – The Princess Bride

6 What Azure Tables Are Not Relational – No concept of Foreign Keys – Able to join to other tables Protected by a schema Database tables – No ORDER BY – No GROUP BY Related in any way to SQL Server

7 What Azure Tables Are Schemaless Entity Bags – Name-value pairs Massively scalable Highly available Durable Cloud Service

8 Table Storage Structure Table Entity … Storage Acct Table … Property … EntityProperty Name Type Value TimeStamp RowKey PartitionKey

9 Required Properties PartitionKey – Enables scalability – Defines the unit of partition RowKey – Unique identifier by partition – With PartitionKey, forms the composite key Timestamp (server managed) – for concurrency

10 Illustrating Partitions PKText T1Going to bed T1I’m super smart, really T2Love me, please… T2Playing XBox T2Just ate meatloaf Vomeets Table Node XNode Y PKText T2Love me, please… T2Playing XBox T2Just ate meatloaf Vomeets Table PKText T1Going to bed T1I’m super smart, really PKText Vomitter Vomeets

11 Partitioning Considerations PartitionKey should be in “WHERE clause” – If it is not, reconsider your architecture – Otherwise scan every partition on n nodes Tradeoff between Entity locality and scalability – Partitions need to be small enough to allow for Scalability Availability – Partitions need to be large enough to allow for Common queries Entity Group Transactions

12 RowKey Considerations RowKey is unique – by partition Together with the PartitionKey, forms the composite key RowKey defines the sort order

13 Agenda I.Overview II.API Overview – REST API III.StorageClient API A.Querying B.Inserting C.Updating D.Deleting IV.Concurrency V.Entity Group Transactions

14 Azure Table Storage APIs REST – Standards – Interoperable - anyone who has HTTP Stack Familiar and easy-to-use API – oData – WCF Data Services –.NET classes and LINQ – Other wrappers – Java, PHP, etc.

15 oData Web Standards compliant protocol Protocol enables querying and updating data Based on ATOM Publishing Protocol HTTP JSON URI

16 WCF Data Services Provides oData clients Enables rapid development of oData services StorageClient API wraps WCF Data Services clients

17 Why wrap REST API Hide complexity of Shared Key Signatures Hide – Creating HTTP Request – Adding appropriate HTTP Headers – Calculating URI – Serializing Request Body – Deserializing Response Body

18 Why use REST API On a platform without a wrapper Unimplemented feature in wrapper

19 DEMO REST API

20 Agenda I.Overview II.API Overview – REST API III.StorageClient API A.Querying B.Inserting C.Updating D.Deleting IV.Concurrency V.Entity Group Transactions

21 Common classes you will work with CloudStorageAccount CloudTableClient TableServiceContext : DataServiceContext DataServiceQuery CloudTableQuery

22 DEMO StorageClient API

23 Agenda I.Overview II.API Overview – REST API III.StorageClient API A.Querying B.Inserting C.Updating D.Deleting IV.Concurrency V.Entity Group Transactions

24 Concurrency When multiple users access data at the same time (concurrently), data integrity can be violated.

25 Optimistic Concurrency Control Assume low contention No locks are taken when data is read No persistent connection required Highly scalable During update: – Check to see if data has changed since read – If yes, rollback – If no, commit

26 Concurrency Client1Azure Customer PartitionKeyCustomerRegion RowKeyCustomerName Address11 Azure Way …… Timestamp2011-03-21T18:11 :18.1733124Z Client2 Customer PartitionKeyCustomerRegion RowKeyCustomerName Address11 Azure Way …… Timestamp2011-03-21T18:11 :18.1733124Z Customer PartitionKeyCustomerRegion RowKeyCustomerName Address11 Azure Way …… Timestamp2011-03-21T18:11 :18.1733124Z Customer PartitionKeyCustomerRegion RowKeyCustomerName Address11 Azure Way …… Timestamp2011-03-21T18 :13:14.1238356Z Customer PartitionKeyCustomerRegion RowKeyCustomerName Address11 Azure Way …… Timestamp2011-03-21T18 :13:14.1238356Z 1. Client1 Issues GET HTTP GET 2. Azure returns the requested entity with a timestamp. (required property for all entities) HTTP Response HTTP GET HTTP Response 3. Client2 requests the same entity HTTP MERGE 4. Client1 issues an HTTP MERGE (PUT/DELETE), passing the timestamp as an HTTP Header 5. Azure checks to see if the passed Timestamp matches the server. If does, so Azure returns 204. Response includes new Timestamp HTTP MERGE 6. Client2 now issues an HTTP MERGE, passing the original Timestamp. 7. Azure checks to see if the Timestamp matches the server. It doesn’t, so server returns 412.

27 Concurrency Process On INSERT / UPDATE, the server maintains a Timestamp When you fetch an entity, the timestamp is returned with the entity When you perform an operation, you send the timestamp as an if-match header (or in the message body in an Entity Group Transaction) If the sent Timestamp != server Timestamp – HTTP Error: 412 – Precondition Failed Sent Timestamp == server Timestamp – Operation succeeds – New Timestamp is returned

28 DEMO Concurrency

29 Entity Group Transactions Batch Insert/Update/Delete – The entire batch is treated as a transaction Call overload of SaveChanges context.SaveChanges(SaveChangesOptions.Batch); SaveChangeOptions – None – ContinueOnError – Batch – ReplaceOnUpdate

30 Entity Group Transactions Constraints – Maximum 100 operations – Maximum payload size: 4 MB – All entities have to have the same partition key – Can perform only 1 operation per entity Snapshot Isolation – No locking required – Snapshot taken at beginning of transaction – Commits only if no concurrency violations Can use context.RetryPolicy

31 DEMO Concurrency


Download ppt "Azure in a Day Azure Tables Module 1: Azure Tables Overview Module 2: REST API – DEMO: Azure Table REST API Module 3: Querying Azure Tables – DEMO: Querying."

Similar presentations


Ads by Google