Getting 401 when running non http azure function locally

Mokarizadeh Shahab (SEBT) 96 Reputation points
2021-06-17T14:33:31.797+00:00

I have Eventhub triggered Azure function (deployed locally as container).

When I want to invoke it locally to test it, I perform following curl command:
curl --location --request POST 'http://localhost:7071/admin/functions/MyFunc' \
--header 'Content-Type: application/json' \
--data-raw '{ "input": "sfslkfldkfldklfkdl" }'

And I expected to get response (2xx) but I get 401 instead (unauthorized error)

I followed this documneation:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http

Any idea where should I look for error?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,887 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ChaitanyaNaykodi-MSFT 25,841 Reputation points Microsoft Employee
    2021-06-17T19:20:57.227+00:00

    Hello @Mokarizadeh Shahab (SEBT) , Thank you for reaching out!

    According to the documentation mentioned here to test the non-http triggered function app locally (except webhooks and Event Grid triggers) you can test your functions locally by calling an administration endpoint. Calling this endpoint with an HTTP POST request on the local server triggers the function.
    For Event Hub triggered function could you refer to the implementation done here by kepalas. Please let me know if you run into any issues here.

    Alternatively

    You can also follow the documentation here to send events to Event Hub using code, but to achieve this you will have deploy a event hub instance on Azure.

    Please let me know if there are any concerns. Thank you!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.