azure-blob-storageshared-access-signatures

Append to an Azure Blob using SAS URL


I need to continuously append to a blob in a container for which I have been provided SAS URL I am doing this

var blobClient =  new AppendBlobClient(mySASUri);
var blobContentInfo = blobClient.CreateIfNotExists();

but Create or CreateIfNotExists do not take a blob name parameter. which is strange for a create method.

and I get Authentication exception when using the following

mySASUri="https://[myaccount].blob.core.windows.net/[my container]?sp=racwl&st=2022-02-03T08:29:46Z&se=2022-02-03T16:29:46Z&spr=https&sv=2020-08-04&sr=c&sig=[the signature]"

I have been reading a lot of stuff on use of Azure SAS but everything talks about generating SAS or stops at very basic level.

Thanks to anyone who looks at this and can provide either a reading reference or guidance on what api combinations should work for this use case.

Thanks, Tauqir


Solution

  • Considering your SAS URL is for the container, it would be be better if you create an instance of BlobContainerClient first and then get an instance of AppendBlobClient using GetAppendBlobClientCore method.

    Something like:

    var blobContainerClient = new BlobContainerClient(new Uri(mySASUri));
    var appendBlobClient = blobContainerClient.GetAppendBlobClientCore("append-blob-name");
    ...do the append blob operations here...