Created
November 22, 2021 05:07
-
-
Save vertonghenb/a68ef82f4d53d71fdf4fdf24563da673 to your computer and use it in GitHub Desktop.
Azure Blob Storage SAS request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Azure.Storage.Blobs; | |
using Azure.Storage.Sas; | |
using System; | |
const string connectionString = "YOUR_CONNECTION_STRING_HERE"; | |
const string containerName = "images"; | |
const string filename = "filename.gif"; | |
BlobServiceClient client = new BlobServiceClient(connectionString); | |
var containerClient = client.GetBlobContainerClient(containerName); | |
BlobClient blobClient = containerClient.GetBlobClient(filename); | |
var blobSasBuilder = new BlobSasBuilder | |
{ | |
ExpiresOn = DateTime.UtcNow.AddMinutes(5), | |
BlobContainerName = containerName, | |
BlobName = filename, | |
}; | |
blobSasBuilder.SetPermissions(BlobSasPermissions.Write | BlobSasPermissions.Create); | |
var sas = blobClient.GenerateSasUri(blobSasBuilder); | |
Console.WriteLine(sas); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment