Search code examples
azureapiazure-functionsazure-api-managementunauthorized

401 unauthorized error when testing endpoint in Azure API


I'm working on azure to make a cloud service for my summer job. I wanted to make an API, calling my database, and it is supposed to be OPEN, meaning if we open a web browser and write the endpoint link, we get the result without a problem. I made a C# azure function as a template a HTTP trigger with Open API.

Locally it works, but when I push it on azure cloud, and when I test it in API management, I get a 401 unauthorized error, no matter the endpoints. I tried uncheck the "require subscription" box, still not working, I tried deleting the API ressource, uncheck the box and then publish, still nothing.

How can I fix it? I just want to make my API fully open without any unauthorization...


Solution

  • I don't have very much experience with API Management. But in order to call an endpoint from API Management you'll have to add the following Header to your request:

    Ocp-Apim-Subscription-Key
    

    The value of this key can be found in the Azure Portal under your API Management resource.

    APIM Azure