locked
GetEventHubs returns an error: (401) Unauthorized. RRS feed

  • Question

  • Hello,

    var namespaceManager = NamespaceManager.CreateFromConnectionString(EventHubConnectionString);
    var client = EventHubClient.CreateFromConnectionString(EventHubConnectionString, EventHubName);            
    var eventhub = namespaceManager.GetEventHub(EventHubName);
    var eventhubs = namespaceManager.GetEventHubs();
    
    The first 3 rows work fine.

    The 4th row (GetEventHubs) throws an exception:

    The remote server returned an error: (401) Unauthorized. Manage claim is required for this operation. TrackingId:a803bc2b-fab5-4107-aa25-a7a9a08ae338_G19,TimeStamp:1/18/2015 7:09:37 AM

    Inner Exception: {"The remote server returned an error: (401) Unauthorized."}

    Please help.

    Thanks,

    Janiv.



    Janiv Ratson. Technology and Development Expert. | BL: http://blogs.microsoft.co.il/blogs/janiv/ | LI: http://www.linkedin.com/in/janiv | TW: http://twitter.com/janiv http://about.me/janiv

    Sunday, January 18, 2015 7:16 AM

Answers

  • Get serviceBusConnectionString from ServiceBus page. Highlight the ServiceBus where you host the eventhub, and click 'Connection String' at the bottom. Then do:

    var namespaceManager = NamespaceManager.CreateFromConnectionString(serviceBusConnectionString);
    var eventhubs = namespaceManager.GetEventHubs();


    Frank

    • Marked as answer by janiv Tuesday, January 20, 2015 10:08 AM
    Monday, January 19, 2015 9:34 PM

All replies

  • You can set the 'listen', 'receive' or 'manage' claims. You need 'manage' claims for the 4th line to work, according to the error message.

    http://msdn.microsoft.com/en-us/library/azure/dn789974.aspx


    Frank

    Sunday, January 18, 2015 2:36 PM
  • Thanks,

    I have manage claim.

    It doesn't work.

    Please help,

    Thanks


    Janiv Ratson. Technology and Development Expert. | BL: http://blogs.microsoft.co.il/blogs/janiv/ | LI: http://www.linkedin.com/in/janiv | TW: http://twitter.com/janiv http://about.me/janiv

    Sunday, January 18, 2015 4:35 PM
  • For EventHubs, you have to use the connection string at the service bus level, not at the event hub level.

    Frank


    • Edited by TChiang Sunday, January 18, 2015 5:45 PM
    Sunday, January 18, 2015 5:44 PM
  • Wonder if you have tried to use the connection string at the service bus level, not at the event hub level as suggested above?

    Frank

    Monday, January 19, 2015 4:14 PM
  • Thanks guys,

    How do I use the connection string at the service bus level?


    Janiv Ratson. Technology and Development Expert. | BL: http://blogs.microsoft.co.il/blogs/janiv/ | LI: http://www.linkedin.com/in/janiv | TW: http://twitter.com/janiv http://about.me/janiv

    Monday, January 19, 2015 7:37 PM
  • Get serviceBusConnectionString from ServiceBus page. Highlight the ServiceBus where you host the eventhub, and click 'Connection String' at the bottom. Then do:

    var namespaceManager = NamespaceManager.CreateFromConnectionString(serviceBusConnectionString);
    var eventhubs = namespaceManager.GetEventHubs();


    Frank

    • Marked as answer by janiv Tuesday, January 20, 2015 10:08 AM
    Monday, January 19, 2015 9:34 PM
  • Hi Frank,

    It worked. Thanks.


    Janiv Ratson. Technology and Development Expert. | BL: http://blogs.microsoft.co.il/blogs/janiv/ | LI: http://www.linkedin.com/in/janiv | TW: http://twitter.com/janiv http://about.me/janiv

    Tuesday, January 20, 2015 10:08 AM