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.
Does azure function support basic authentication?
zmsoft
180
Reputation points
Hi there,
Does azure function support basic authentication? Not use app key in url , use authorization header in request.
Thanks
2 answers
Sort by: Most helpful
-
-
Khadeer Ali 1,300 Reputation points Microsoft Vendor
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 theAuthorization
header can still pass through. To ensure that only requests with valid credentials are allowed, change theAuthorizationLevel
toFunction
[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 theConfigureAppConfiguration
method.Uncomment and adjust the following:
.ConfigureAppConfiguration(app => { app.UseAuthentication(); })
- Ensure that your function app is processing authentication middleware correctly.For that, you should call
- Double-check that the
Authorization
header is being parsed correctly and handle any errors gracefully.
If this answers your query, do click
accept answer
andyes
for was this answer helpful. And, if you have any further query do let us know. - In your function, the