Azure function receiving 401, when publishing events to a eventhub

Anupama Sathuluri 1 Reputation point Microsoft Employee

I am working on an Azure Function which sends data as a producer to an Event Hub. Azure function is in a different tenant/subscription and Event Hub in a different one. I was able to send data to EventHub from the Functionapp while running a project in my local machine via local-host.

But when i deployed the function to Azure Cloud i am getting the following exception when publishing the data to Eventhub.

Catching an exception: status-code: 401, status-description: Unauthorized TrackingId:XXXX-XXXXX

Event Hub and Function App are in different tenants, different subscriptions. ACL is open between them. Before the ACL is open, got connection closed error and now the above error.

Are any additional firewall or networking updates required on the EventHub?

Thanks in advance.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,657 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
599 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,006 Reputation points

    anonymous user Thanks for reaching out. As per the error status-code: 401, status-description: Unauthorized TrackingId:XXXX-XXXXX the client (function app) was not able to authenticate the request for event hub. As per the sample it looks like you are using the Azure Event Hub SDK for sending the event and not the event hub output bindings.

    I will suggest you to validate if you are passing the correct connectionString and log the connectionString object to verify if the value was retrieved correctly. As you haven't shared the full code snippet/configuration, I am not sure how you can getting the connectionString.

    In case as you have confirmed that it works locally and not when deployed in azure function so I believe you are getting the connection string from your local.setting.json file.
    Please verify if the same configuration in local.setting.json file is reflected in the configuration blade of your function app.

    If it is not the above case, then please share your sample code and configuration so I can review it.