Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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