Azure Table Storage Creation using Nov 2009 CTP
Posted
by kaleidoscope
on Geeks with Blogs
See other posts from Geeks with Blogs
or by kaleidoscope
Published on Mon, 22 Mar 2010 03:32:34 GMT
Indexed on
2010/03/22
4:41 UTC
Read the original article
Hit count: 358
The new SDK introduces a new class -
· The CloudTableClient : This new class enables us to create tables and test for the existence of tables. We need not need use this class for querying table storage, it's more of an administrative class for dealing with table storage itself.
· Once we have got the account key and the account name from ConfigurationSetting, we can create an instance of the storage credentials and table client classes:
StorageCredentialsAccountAndKey creds = new StorageCredentialsAccountAndKey(accountName, accountKey);
CloudTableClient tableStorage = new CloudTableClient(tableBaseUri, creds);
CustomerContext ctx = new CustomerContext(tableBaseUri, creds);
//where tableBaseUri is the TableStorageEndpoint obtained from ConfigurationSetting
Using the table storage class, we can now create a new table (if it doesn't already exist):
if (tableStorage.CreateTableIfNotExist("Customers"))
{
CustomerRow cust = new CustomerRow("AccountsReceivable", "kevin");
cust.FirstName = "Kevin";
cust.LastName = "Hoffman";
ctx.AddObject("Customers", cust);
ctx.SaveChanges();
}
For a complete article on this topic please follow this link:
http://dotnetaddict.dotnetdevelopersjournal.com/azure_nov09_tablestorage.htm
© Geeks with Blogs or respective owner