Use msal TokenCache when using BlobClient to read and write BlobStorage

Avi Stokar 6 Reputation points
2021-03-16T15:49:26.6+00:00

In my desktop app (which has permission to access Azure Storage), the user logs in at startup using MSAL with a tokenCache. I then want to read and write to Blob Storage without having to re-authenticate the user. In the previous version of the library I was able to pass the Bearer token from the AuthencatioResult.

Using Azure.Identity I am hoping there is a way to setup the DefaultAzureCredential (or something else) to retrieve the cached credential.

Any help is appreciated.

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,715 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,436 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,569 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. deherman-MSFT 33,626 Reputation points Microsoft Employee
    2021-03-17T21:24:03.74+00:00

    @Avi Stokar
    Here is a great blog post by one of our Microsoft Engineers that you might find helpful. As discussed in the blog, the default Azure Storage client doesn’t work directly with MSAL (for now), so even though our user has already authenticated, we would need to reauthenticate them in order to interact with the Azure Storage account. This is not a particularly smooth user experience. To address this, we will build a custom Token provider to directly pass our own Access token and avoid multiple round trips to Azure AD.

    Please checkout the code to build a custom token provider to see if it resolves your issue. If you have further questions please let us know and we will do our best to assist.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments