azure function aad code example
Example: azure function aad
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.Security.Claims;
using System.Linq;
namespace Auth1
{
public static class Function1
{
[FunctionName("Function1")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req,
ClaimsPrincipal principal,
ILogger log)
{
return new OkObjectResult(new
{
Name = principal.Identity.Name,
IsAuthenticated = principal.Identity.IsAuthenticated,
Claims = principal.Claims.Select(x => new { Type = x.Type, Value = x.Value }).ToArray(),
});
}
}
}