Answers for "generate sas token for azure blob"

0

generate sas token for azure blob

Azure.Storage.Sas.BlobSasBuilder blobSasBuilder = new Azure.Storage.Sas.BlobSasBuilder()
        {
            BlobContainerName = "demo-copy",
            BlobName = "test.txt",
            ExpiresOn = DateTime.UtcNow.AddMinutes(5),//Let SAS token expire after 5 minutes.
        };
        blobSasBuilder.SetPermissions(Azure.Storage.Sas.BlobSasPermissions.Read);//User will only be able to read the blob and it's properties
        var sasToken = blobSasBuilder.ToSasQueryParameters(new StorageSharedKeyCredential(accountName, accountKey)).ToString();
        var sasUrl = blobClient.Uri.AbsoluteUri + "?" + sasToken;
Posted by: Guest on September-02-2021

Browse Popular Code Answers by Language