1
votes

I have to send message to Queue. I have specified connection string in app.config. I already set SharedAccessKeyName and SharedAccessKey on azure and set in connection string.

I am using below console code to send message.

string connString =  ConfigurationSettings.AppSettings["Microsoft.ServiceBus.ConnectionString"];
NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(connString);


            QueueClient client = QueueClient.CreateFromConnectionString(connString, "testqueue");
            BrokeredMessage message = new BrokeredMessage("test");
            client.Send(message);
            Console.ReadLine();

I am getting error:

40103: Invalid authorization token signature ...

How to resolve this issue?

2
Please edit your question and include the connection string? Please replace account name and key with some dummy values.Gaurav Mantri

2 Answers

2
votes

How to resolve this issue?

According to your mentioned excetpion Invalid authorization token signature, I assume the error occured in the connection string.

Endpoint=sb://{servicebusName}.servicebus.windows.net/;SharedAccessKeyName={policyName};SharedAccessKey=xxxx";

We could get it from the azure portal, more details you could refer to the screenshot. We also could refer to Get started with Service Bus queues.

enter image description here

Note: If you use added SAS Policy, please make sure it has access to send message.

enter image description here

0
votes

When generating the SAS token, for example using C#, pass the following:

  • resourceUri should be without the trailing '/messages'
  • key should be the SharedAccessKey, instead of the full connection string.