question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Renew SasKey for BlobContainerClient

See original GitHub issue

Library name

Azure.Storage.Blobs

Please describe the feature.

Hi,

We receive 1 hour write sas key and were wondering how to renew it once the BlobContainerClient is created.

For example:


var containerclient = new BlobContainerClient(new Uri("https://storageaccount.blob.core.windows.net/containername?sig=something")
// Start upload
// 1 hour later, the sas key is expired and the upload fails.

How can we deal with this case? Is there a way to give a callback for new signature? Should I implement a custom TokenCredential or implement a custom HttpClientTransport and modify the Uri on the fly with a renewed signature? Or others method?

Please advise.

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
amnguyecommented, Aug 4, 2023

Hi, you can use the AzureSasCredential instead when instantiating your client.

So it would something like

AzureSasCredential credential = new AzureSasCredential(sas);
BlobContainerClient containerClient = new BlobContainerClient(uri, credential, options);

Then when your SAS expires you could do something like

// Wait 1 hour
credential.Update(newSas);
0reactions
BeChaRemcommented, Aug 14, 2023

Thanks for the answer, exactly what I was looking for.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Renew SasKey for BlobContainerClient
This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer...
Read more >
Create a service SAS for a blob with .NET - Azure Storage
This article shows how to use the storage account key to create a service SAS for a blob with the Azure Blob Storage...
Read more >
Create a user delegation SAS for a blob with .NET
The user delegation key is independent of the OAuth 2.0 token used to acquire it, so the token doesn't need to be renewed...
Read more >
Uploading Files to Azure Blob Storage with Shared Access ...
Shared Access Signature (SAS) provides a secure way to upload and download files from Azure Blob Storage without sharing the connection string.
Read more >
'Server failed to authenticate the request' when attempting ...
Updated Solution: I have tested Azure.Storage.Blobs package version 12.11.0, and gives the exact issue OP described in the question.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found