Share via

Does azure function support basic authentication?

zmsoft 695 Reputation points
2024-11-11T00:43:23.6733333+00:00

Hi there,

Does azure function support basic authentication? Not use app key in url , use authorization header in request.

Thanks

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.


2 answers

Sort by: Most helpful
  1. Anonymous
    2024-11-12T08:47:11.97+00:00

    Hi @zmsoft,

    Welcome to the Microsoft Q&A Platform! Thank you for reaching out regarding the basic Authentication for Azure Functions.

    • In your function, the AuthorizationLevel.User allows anonymous access, which is why requests without the Authorization header can still pass through. To ensure that only requests with valid credentials are allowed, change the AuthorizationLevel to Function
        [Function("Function1")]
        public async Task<IActionResult> NewOrder([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)
      
      • Ensure that your function app is processing authentication middleware correctly.For that, you should call app.UseAuthentication() in the ConfigureAppConfiguration method.Uncomment and adjust the following:
        .ConfigureAppConfiguration(app =>
        {
            app.UseAuthentication();
        })
      
    • Double-check that the Authorization header is being parsed correctly and handle any errors gracefully.

    If this answers your query, do click accept answer and yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

  2. S.Sengupta 30,261 Reputation points MVP Volunteer Moderator
    2024-11-11T01:17:45.8633333+00:00

    Azure Functions supports basic authentication through several methods. For HTTP-triggered functions, one can implement basic authentication (username/password in Authorization header) by creating a custom authentication handler.


Your answer

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