Search code examples
azure-eventhub

Unauthorized error when using SendListen shared access key to GetConsumerGroupAsync


We started observing following error from yesterday while we are trying to access Consumer Group using SendListen Key. It is throwing Unauthorized error. If I use RootManagerSharedAccessKey, this works fine.

var connectionString = "Endpoint=sb://*****.servicebus.windows.net/;SharedAccessKeyName=SendListen;SharedAccessKey=****";
        var ns = NamespaceManager.CreateFromConnectionString(connectionString);
        var result= ns.GetConsumerGroupAsync("**", "**").GetAwaiter().GetResult();

Exception: 'The remote server returned an error: (401) Unauthorized. TrackingId:e2993246-9253-4cb7-ab54-2a9b32abfec7, SystemTracker:*.windows.net:dataoffload/ConsumerGroups/, Timestamp:8/11/2017 12:33:46 AM'

Any recent changes in EventHub?


Solution

  • According to your description, I checked this issue on my side. Here is my test, you could refer to it.

    SETTING > Shared access policies

    enter image description here

    Code snippet:

    var connString = "Endpoint=sb://{my-hubname}.servicebus.windows.net/;SharedAccessKeyName=SendListen;SharedAccessKey=aTu3sxJ1TMLXDWN6ErkHp28aVL/Fstfa49MkuibbQ7A=";
    var ns = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(connString);
    var result = ns.GetConsumerGroupAsync("myhub01", "$Default").GetAwaiter().GetResult();
    

    Upon the settings, I could retrieve the description of my consumer group. Also, for the single Listen policy, it could work as well. Based on your error, I would recommend you checking your CONNECTION STRING. Also, you could leverage fiddler to collect the network traces for details.