Best approach for converting web APIs to Azure functions?

I am working on converting WebAPI endpoints to Azure Functions. Our WebApi has several user attributes that handle authentication, how do I convert them to Azure Functions?

As an example, here is the AuthorizeAttribute attribute:

public class MyAuthorizationAttribute : AuthorizeAttribute
{
        public override async Task OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
        {
            if (!AuthorizationHelper.SkipAuthorization(actionContext))
            {
                // Some auth logic here generating a ClaimsPrincipal omitted..
                HttpContext.Current.User = principal;
                await base.OnAuthorizationAsync(actionContext,cancellationToken);
            }
       }
}

In WebAPI: HttpContext.Current.Userto get the caller In Azure Function: no HttpContext

+4
source share

Source: https://habr.com/ru/post/1685232/


All Articles