You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I want to call the api and at the function decides what level of info to show/return based on user's roles.
Can someone give a sample on how to get logged user's roles in Azure Function on static web app?
When deploying Azure Function via "Function App", I can get the roles and current username, but with "Static Web App" I haven't figured it out yet.
namespaceFunction1{publicclassFunction1{[FunctionName("Function1")]publicstaticasyncTask<IActionResult>Run([HttpTrigger(AuthorizationLevel.Anonymous,"get","post",Route=null)]HttpRequestreq,ClaimsPrincipalprincipal){IEnumerable<string>roles=principal.Claims.Where(e =>e.Type.Equals("roles")).Select(e =>e.Value);stringname=principal.Identity.Name;stringresponseMessage=$"Hello, {name}. This HTTP triggered function executed successfully. {string.Join(',',roles)}";returnnewOkObjectResult(responseMessage);}}}
Hi, I want to call the api and at the function decides what level of info to show/return based on user's roles.
Can someone give a sample on how to get logged user's roles in Azure Function on static web app?
When deploying Azure Function via "Function App", I can get the roles and current username, but with "Static Web App" I haven't figured it out yet.