Azure Examples
Exploring Windows Azure services.
NOTE
On 2008-12-16, this server will undergo extensive maintenance including relocation. The site may be down
for 24 hrs or more. Sorry for the nconvenience. I'll have the server back up as quickly as possible.
ATTENTION:
These examples only work if you have a valid Azure Storage project and shared key. If you don't have one,
you can visit the Azure web site to request one.
Azure.exe - Added support for Table continuation headers
2008-12-14
It was pointed out that Azure.exe was not honoring the continuation header for Table queries
(x-ms-NextTableName
).
This has been fixed. I also added several static XML files that are the results of Table and Entity
queries for both Feeds and single Entries. These can be used to validate the Azure Atom output
against the W3C Atom validator.
GoogleCode Source Hosting
2008-12-13
All the code for my Azure Examples can now be found at GoogleCode. This is an SVN-based
site and is a bit friendlier than the github I've been using for daily check-ins. The GoogleCode site will be
updated for each major change and not for each and every daily mod. If you're interested in 'the big picture'
releases, this one will get you what you need.
Azure.exe - Added support for continuation headers
2008-12-12
I added support for Azure's "paging" continuation headers. Now, when you execute a query using
the $top=n
argument, Azure.exe
will automatically check the
response headers and, if the x-ms-contination-NextParitionKey
and
x-ms-NextRowkey
headers are returned, you'll see a prompt for [n]ext or e[x]it.
This was a pretty simple addition. While I prefer the
paging pattern proposed for Atom,
this one works well for 'forward-only' cursor-style.
NOTE
Thanks goes to Steve Marx for his
blog post explaining the continuation header.
I lifted several things from
that post. If the paging works, it's due to his efforts. However, if it fails, it's all my doing [grin].
Azure.exe - Command-line app for Table Storage
2008-12-11
This is a 'full-blown' CLI (command-line interface) for your Azure Table Storage.
It supports GET, POST, and DELETE for Tables; GET, POST, PUT, MERGE, and DELETE for
Entities; and ad-hoc queries against Entities. It honors ETags and uses them for
successful PUT, MERGE, and DELETE requests against the server stores. Below is
the ShowHelp()
output that summarizes the syntax:
Tables:
/{tid} [[g]et]
ex: /my-table
/{tid} [p]ost
ex: /my-new-table p
Entities:
/{tid}/ [[g]et]
ex: /my-table/
/{tid}/{pid},{rid} [[g]et]
ex: /my-table/my-partition,my-row
/{tid}/{pid},{rid} [p]ost "{xml}|{filename}"
ex: /my-table/my-partition,myrow p c:\new-properties.xml
/{tid}/{pid},{rid} p[u]t "{xml|filename}"
ex: /my-table/my-partition,my-row u c:\modified-properties.xml
/{tid}/{pid},{rid} [m]erge "{xml|filename}"
ex: /my-table/my-partition,my-row m c:\partial-properties.xml
/{tid}/{pid},{rid} [d]elete
ex: /my-table/my-partition,my-row d
Queries:
/{tid}/? "{query}" [[g]et]
ex: "?Customers()?$filter=(InvoiceOnFile eq true)&top=10"
AzureTest - Command-line GET utility
2008-12-09
This is a simple app that requests data from your Azure Tables account. I built this to
validate hashing, handling requests, and sniffing returns for things like continuation
headers, ETag caching, etc. It's probably not very interesting unless you want to
dig into it to pull out a few bits for your own use.
CreateTable - Command-line POST utility
2008-1208
My first Azure Tables app. This tiny demo creates a new table in the Azure Table Storage system.
This is done using plain old HTTP. No Azure SDKs; No Vista; No Visual Studio 2008; No .NET 3.51.
Just .NET 2.0 C# and WebRequest/WebResponse. all just to prove I can, actually.
The most interesting code in this demo is stuff that handles MSFT's custom authentication header
(boo, hiss). There are several 'flavors' of auth headers for Azure (based on service,
code library, and target (dev or live). This version works for live Azure Table Storage only. It's
the one I plan on using most often. See the snippet below and download the code for the whole story.
// build up azure SharedKey hash
string authValue = string.Format(fmtStringToSign, method, contentMD5, contentType, reqDate, canonicalResource);
string sigValue = ComputeMacSha(authValue, Convert.FromBase64String(authKey));
string authHeader = string.Format(fmtHeader, keyType, account, sigValue);
// hashing helper
private static string ComputeMacSha(string canonicalizedString, byte[] key)
{
byte[] dataToMAC = System.Text.Encoding.UTF8.GetBytes(canonicalizedString);
using (HMACSHA256 hmacsha1 = new HMACSHA256(key))
{
return System.Convert.ToBase64String(hmacsha1.ComputeHash(dataToMAC));
}
}