0
votes

I am trying to build a Single Page App with Azure Functions so that when user wants to visit my website they can visit the url of my azure function which will be a custom domain, like www.contoso.com

But when they visit it first they must automatically go to login page for Azure AD B2C and after they login they get redirected to my SPA with their info.

I know how to create a SPA with azure functions without authentication, and I also know how to configure an azure b2c tenant, I've also added azure ad b2c authentication into Azure Function -> Authentication -> Azure AD -> Advanced.

My question is, how can I initiate the login process for the user, just like in a normal website. In a normal asp website, visual studio provides options to integrate this, but how can I do the same for azure functions?

1

1 Answers

1
votes

My question is, how can I initiate the login process for the user, just like in a normal website. In a normal asp website, visual studio provides options to integrate this, but how can I do the same for azure functions?

To init the login progress for Azure function which triggered by HTTP, you can login it manually by providing the login URL. The login URL is in the format of {your App Service base URL}/.auth/login/. In this scenario, the value of provider is aad. And it is similar with the authentication for the app service. After the authentication, you should get the authentication token from Easy Auth. Then you can use this token to call the Azure Function like request below:

GET: https://{functionBaseURL}/api/{functionName}?{parameters}

X-ZUMO-AUTH: {authenticationToken}