In Net Framework 461 use Managed Identity as token credential access Azure Storage Table fail.

Binjie Li (Shanghai Wicresoft Co,.Ltd.) 20 Reputation points Microsoft Vendor
2023-12-07T04:47:48.7866667+00:00

In Net Framework 4.6.1. When I use below code to access table:

AccessToken token = new DefaultAzureCredential(
    new DefaultAzureCredentialOptions()
    {
        ManagedIdentityClientId = "{Managed Identity Client ID}"
    })
    .GetToken(new Azure.Core.TokenRequestContext(new[] { "https://storage.azure.com/.default" }));
Microsoft.WindowsAzure.Storage.Auth.TokenCredential tokenCredential = new Microsoft.WindowsAzure.Storage.Auth.TokenCredential(token.Token);
StorageCredentials storageCredentials = new StorageCredentials(tokenCredential);
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(storageCredentials, "{Account Name}", "core.windows.net", true);

CloudTable cloudTable = cloudStorageAccount.CreateCloudTableClient().GetTableReference("{Table Name}");
cloudTable.CreateIfNotExistsAsync();

It throws an error message: Token credential is not supported for this service. But use this way can access blob and queue.

When I use Net 6.0 to run this code, it will can access table.

Azure Table Storage
Azure Table Storage
An Azure service that stores structured NoSQL data in the cloud.
171 questions
{count} votes

Accepted answer
  1. Anand Prakash Yadav 7,795 Reputation points Microsoft Vendor
    2023-12-07T13:14:50.2233333+00:00

    Hello Binjie Li (Shanghai Wicresoft Co,.Ltd.),

    Thank you for posting your query here!

    It looks like you're using Azure Storage with Managed Identity to access a table using the Azure Storage SDK for .NET in the context of .NET Framework 4.6.1. The error you're encountering indicates that token credentials are not supported for table storage in that specific version of the SDK.

    For .NET Framework 4.6.1, the Microsoft.WindowsAzure.Storage library is commonly used to interact with Azure Storage services, including tables. There might be limitations in the Microsoft.WindowsAzure.Storage library for using token credentials with Azure Storage Table in .NET Framework 4.6.1.

    If you need to work specifically with Azure Storage Table and require token credentials, consider exploring alternative approaches, such as using a different library (Azure.Data.Tables) or upgrading to a newer version of .NET Framework.

    Kindly let us know if you have any further queries. I’m happy to assist you further.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.