Skip to content

Instantly share code, notes, and snippets.

@chechedotmx
Created September 13, 2013 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chechedotmx/6546396 to your computer and use it in GitHub Desktop.
Save chechedotmx/6546396 to your computer and use it in GitHub Desktop.
This codes retreives an existing blob with permissions to read, Azure Blob, C# Then for example we get this data to a byte array
public String GetBlobUriWithSAS(String containerName, String blobName)
{
CloudBlobContainer container = this._blobClient.GetContainerReference(containerName);
container.CreateIfNotExists();
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);
String sharedAccesSignature = blockBlob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
{
Permissions = SharedAccessBlobPermissions.Read,
SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromMinutes(10)
});
return blockBlob.Uri.AbsoluteUri + sharedAccesSignature;
}
//Getting this on a bytearray
var webClient = new WebClient();
byte[] byteArrayToRetreive = webClient.DownloadData(UriWithSAS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment