AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

TokenCredential tokens expire in long-running processes (such as in Azure App Service)

Open luyseyal opened this issue 7 years ago • 3 comments

var credentials = new StorageCredentials(new TokenCredential(token)); The problem with this example is that TokenCredential will expire and throw exceptions in a long-running process. Can you give an example with the TokenCredential constructor with auto refreshing?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

luyseyal avatar Aug 09 '19 05:08 luyseyal

The article is about key storage providers,, not obtaining tokens.

Rick-Anderson avatar Aug 09 '19 11:08 Rick-Anderson

@Rick-Anderson Here is an example you can use (or link to in your document) that renews tokens properly.

https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-msi?toc=%2Fazure%2Fstorage%2Fqueues%2Ftoc.json#net-code-example-create-a-block-blob

luyseyal avatar Aug 26 '19 16:08 luyseyal

A solution was offered here dotnet/aspnetcore#9012 to use the constructor of TokenCredential that takes a func to refresh the token after a certain period.

Rick-Anderson avatar Apr 06 '20 17:04 Rick-Anderson