Working with the Table service REST API in Visual C#.NET

Creating Code128 in Visual C#.NET Working with the Table service REST API

Working with the Table service REST API
Painting Code 128 Code Set B In C#
Using Barcode drawer for .NET framework Control to generate, create Code128 image in .NET framework applications.
www.OnBarcode.com
Scanning Code 128 Code Set A In Visual C#
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
This chapter covers
Make Quick Response Code In C#
Using Barcode creator for VS .NET Control to generate, create QR image in .NET applications.
www.OnBarcode.com
Making Code 39 In Visual C#.NET
Using Barcode drawer for VS .NET Control to generate, create Code 39 image in Visual Studio .NET applications.
www.OnBarcode.com
Introducing the StorageClient library and REST API Understanding how to effectively modify data Querying the Table service
Generate ECC200 In C#.NET
Using Barcode creation for .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications.
www.OnBarcode.com
GTIN - 12 Creation In Visual C#
Using Barcode creation for Visual Studio .NET Control to generate, create UPC Symbol image in .NET framework applications.
www.OnBarcode.com
In the previous chapter, we looked at how to get started with the Table service using the StorageClient library and the WCF Data Services client. In this chapter, we ll look at the underlying REST API to gain a better understanding of the communication between applications and the Table service. WCF Data Services is an implementation of the OData protocol. OData defines how to work with and exchange data over REST-based services. The Table service implements OData, and the StorageClient library acts as a WCF Data Services client. Even with these layers of abstraction, understanding how to query and update data using the REST API will help you to truly understand what is happening under the covers when using the WCF Data Services based Table service API. Let s get started by looking at how you can perform operations directly against the REST API.
Draw Barcode In Visual C#.NET
Using Barcode creation for VS .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Generating ANSI/AIM Codabar In C#.NET
Using Barcode generation for Visual Studio .NET Control to generate, create Uniform Symbology Specification Codabar image in VS .NET applications.
www.OnBarcode.com
Working with the Table service REST API
Scanning Code128 In .NET Framework
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Code-128 Encoder In None
Using Barcode generator for Font Control to generate, create Code 128C image in Font applications.
www.OnBarcode.com
12.1 Performing storage account operations using REST
Decoding PDF-417 2d Barcode In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Paint EAN-13 In Java
Using Barcode printer for Java Control to generate, create EAN / UCC - 13 image in Java applications.
www.OnBarcode.com
For now, we ll concentrate purely on the operations that you can perform against a storage account using the REST API. Although we ve already looked at these operations using the StorageClient library, it s still useful to look at the REST API. Ultimately, the StorageClient library is just a wrapper library for the calls we re about to look at. Over the next few sections, we ll look at the following operations: Listing tables Deleting tables Creating tables In chapters 8 10 on BLOBs, we described how you could interact with the storage services using various endpoints. We won t go over that subject again in this chapter, but it s worth looking at the endpoint URI of the Table service. The URI of the Table service endpoint uses the following structure:
Paint Code 3/9 In .NET
Using Barcode printer for VS .NET Control to generate, create Code 3 of 9 image in .NET applications.
www.OnBarcode.com
EAN 128 Creation In Visual Basic .NET
Using Barcode generation for .NET framework Control to generate, create EAN / UCC - 13 image in Visual Studio .NET applications.
www.OnBarcode.com
http://<storageaccount>.table.core.windows.net/
Reading Code 3/9 In VS .NET
Using Barcode reader for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Recognizing UPC Code In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
If your storage account was named silverlightukstorage, your URI would be the following:
Code 39 Full ASCII Recognizer In Visual Basic .NET
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Read Code39 In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
http://silverlightukstorage.table.core.windows.net/
EAN13 Encoder In Java
Using Barcode creation for Java Control to generate, create GS1 - 13 image in Java applications.
www.OnBarcode.com
Printing ECC200 In Objective-C
Using Barcode maker for iPad Control to generate, create Data Matrix 2d barcode image in iPad applications.
www.OnBarcode.com
For the development storage Table service, you d use the following URI:
http://127.0.0.1:10002/devstoreaccount1/
Now that you know what the URIs will look like, let s try using them.
12.1.1 Listing tables in the development storage account using the REST API
In chapter 9, we looked at a small console application that listed all the containers in a BLOB storage account using the REST API. In this section, you ll create a similar console
Figure 12.1 A console application that returns a list of tables in a storage account that s a lot of XML just to return a list containing the name of one table.
Performing storage account operations using REST
application that will list all the tables in a development storage account. Figure 12.1 shows the output of this console application. If you look at the output in figure 12.1 you can see that the Products table (created in the previous chapter) is returned in the list of storage accounts.
Does that funny-looking XML follow some sort of standard
As you may have already gathered, normal people don t create APIs that output XML like what you see in figure 12.1. You need a standard to generate that level of verboseness and complexity. The standard that the Table service uses to expose its data is known as AtomPub. We ll discuss it in more detail later. If you re interested in being able to identify AtomPub documents in the wild, you can always look at the XML namespace. As you can see in figure 12.1, it s referencing the Atom namespace:
xmlns=http://www.w3.org/2005/Atom
If you wanted to list all the tables in a storage account using the StorageClient library, you could do the following:
var storageAccount = CloudStorageAccount.Parse( ConfigurationManager.AppSettings["DataConnectionString"]); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); tableClient.ListTables();
Let s now take a look at how this could be done using the REST API directly. You might not usually do this directly with REST, but we want you to appreciate what s really happening behind the scenes. In order to get a list of all tables that exist in the storage account, all you need to do is write some code that will perform a GET request against the following URIs:
http://127.0.0.1:10002/devstoreaccount1/Tables (for dev storage) http://<storageaccount>.table.core.windows.net/Tables (for live)
To create the application that generated the output shown in figure 12.1, you ll need to create a new console application in Visual Studio. To keep the example simple, we ll reuse the StorageClient library s credential-signing method. You ll need to add a reference to this assembly this is the same assembly that you used in the previous chapter. The following listing contains the code for the console application.
Copyright © OnBarcode.com . All rights reserved.