DCSIMG
July 2010 - Posts - Manu Cohen-Yashar's Blog

Manu Cohen-Yashar's Blog

July 2010 - Posts

Blob Shared Access Signatures Sample

Shared Access Signatures allows to provide access rights to containers and blobs at a more granular level than by simply setting a container’s permissions for public access.
By specifying a Shared Access Signature, you can grant users access to a specific blob or to any blob within a specified container for a specified period of time.
You can also specify what operations a user may perform on a blob that's accessible via a Shared Access Signature. Supported operations include:

•Reading and writing blob content, block lists, properties, and metadata
•Deleting a blob
•Leasing a blob
•Creating a snapshot of a blob
•Listing the blobs within a container

Both block blobs and page blobs support Shared Access Signatures.
A Shared Access Signature is a set of URL query parameters that incorporates all of the information necessary to grant controlled access to a blob or container resource.
The URL specifies the time interval over which the Shared Access Signature is valid, the permissions that it grants, the resource that is to be made available, and the signature that the Blob service should use to authenticate the request.

The URL for the Shared Access Signature may reference a container-level access policy that provides an additional level of control over a set of signatures,
including the ability to modify or revoke access to the resource if necessary.

I wrote a simple demo to demonstrate this:

public static string CreateBlob()

{

   var cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;

 

   var blobClient = cloudStorageAccount.CreateCloudBlobClient();

   var container = blobClient.GetContainerReference("sas");

   container.CreateIfNotExist();

   CloudBlob blob = container.GetBlobReference("test.txt");

   blob.UploadText("This is a test blob.");

   string sas = GenerateSAS(container, blob);

   return blob.Uri.AbsoluteUri + sas;

}

 

public static string ReadBlob(string uri)

{

    CloudBlob blob = new CloudBlob(uri);

    return blob.DownloadText()

}

 

 

static void Main(string[] args)

{

  var uri = CreateBlob();

  Console.WriteLine("{0}", uri);

  string str = ReadBlob(uri);

  Console.WriteLine(str);           

 

  Console.WriteLine("Press ENTER to exit");

  Console.ReadLine();

}

 

What's new in WCF 4.0 Presentation

Yesterday I gave a talk about WCF 4.0

Here is the presentation and demos

(make sure to change the file type back to rar and pptx)

Manu