0

I'm trying to create a servicebus client using the following code:

ServiceBusClient sbClient = new ServiceBusClient("xxxx.servicebus.windows.net", new DefaultAzureCredential());

However, when I try to do anything with it, i.e. create a sender and send a message, I get the following error: "claim is empty or token is invalid"

I'm also getting a similar issue when I do the same thing with a QueueClient(), however, the error message is:

"Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature"

AJames
  • 59
  • 6
  • 1
    I take it you already authenticated VS Code or VS, following these guidelines? https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md#authenticating-via-visual-studio – Kristin Aug 19 '22 at 07:22
  • Yes I am following those guidelines for VS – AJames Aug 22 '22 at 03:05
  • And no answers found in https://stackoverflow.com/questions/24492790/azurestorage-blob-server-failed-to-authenticate-the-request-make-sure-the-value solve the problem? – Kristin Aug 22 '22 at 06:44

1 Answers1

1

I needed to add the TentantID as both an environment variable but also as a property in the VisualStudioCredentialOptions() (https://learn.microsoft.com/en-us/dotnet/api/azure.identity.visualstudiocredentialoptions?view=azure-dotnet) that are passed into the VisualStudioCredential() object (https://learn.microsoft.com/en-us/dotnet/api/azure.identity.visualstudiocredential?view=azure-dotnet).

AJames
  • 59
  • 6
  • Thank you, this did the trick for me, just needed to add the `AZURE_TENANT_ID` environment profile to my debug profile and then everything worked – Neil Stevens Aug 15 '23 at 10:07