Useful extension methods for Windows Azure storage operations that aren't covered by the .NET client library
C#
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.nuget
Properties DateTime is awful. DateTimeOffset is the replacement. Aug 10, 2012
.gitignore adding dependency on WindowsAzure.StorageClient 1.7 Jun 14, 2012
AutoRenewLease.cs
ExistenceExtensions.cs initial commit Sep 2, 2011
InitializationExtensions.cs
LICENSE adding Ms-PL license Oct 22, 2011
LeaseExtensions.cs better handle exceptions with no response (by bubbling them up) Aug 9, 2012
README.md get rid of samples no longer relevant Aug 10, 2012
WazStorageExtensions.csproj remove things that are now covered by the official .NET storage clien… Aug 9, 2012
WazStorageExtensions.nuspec adding dependency on WindowsAzure.StorageClient 1.7 Jun 14, 2012
WazStorageExtensions.sln initial commit Sep 2, 2011
build.cmd initial commit Sep 2, 2011
packages.config

README.md

WazStorageExtensions

smarx.WazStorageExtensions is a collection of useful extension methods for Windows Azure storage operations that aren't covered by the .NET client library.

It can be install using the NuGet package via install-package smarx.WazStorageExtensions and contains extension methods and classes for the following:

Basic Usage

This console app initializes storage by creating a container, queue, and table:

public static void Main(string[] args)
{
    var account = CloudStorageAccount.Parse(args[0]);
    account.Ensure(containers: new [] { "mycontainer" }, queues: new [] { "myqueue" }, tables: new [] { "mytable" });
}

This console app tries to acquire a lease on a blob, and (if it succeeds), writes "Hello World" in the blob:

static void Main(string[] args)
{
    var blob = CloudStorageAccount.Parse(args[0]).CreateCloudBlobClient().GetBlobReference(args[1]);
    var leaseId = blob.TryAcquireLease();
    if (leaseId != null)
    {
        blob.UploadText("Hello, World!", leaseId);
        blob.ReleaseLease(leaseId);
        Console.WriteLine("Blob written!");
    }
    else
    {
        Console.WriteLine("Blob could not be leased.");
    }
}

This console app tests for the existence of a blob:

static void Main(string[] args)
{
    var blob = CloudStorageAccount.Parse(args[0]).CreateCloudBlobClient().GetBlobReference(args[1]);
    Console.WriteLine("The blob {0}.", blob.Exists() ? "exists" : "doesn't exist");
}