How to add app authentication to the azure function for the authenticating tokens generated by azure ad b2c

Likitha Bommasani 0 Reputation points
2025-01-27T18:56:04.2633333+00:00

I am using Azure AD B2C for user sign-up and sign-in. When a user signs in, both an access token and an ID token are issued.

I have Azure Functions hosted in my primary tenant, and I want to authenticate users before running my azure function using Azure Function App Authentication or Azure Function Runtime Authentication.

How can I configure the Azure Functions so they will:

  1. Accept tokens issued by Azure AD B2C.
  2. Verify the tokens correctly.

Could you guide me through the necessary steps or configurations to achieve this?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,373 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ranashekar Guda 5 Reputation points Microsoft Vendor
    2025-01-28T10:00:28.5533333+00:00

    Hi @Likitha Bommasani ,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    To implement app authentication for your Azure Functions using Azure AD B2C, you can follow these steps:

    • Make sure your Azure AD B2C tenant is set up with the required user flows for sign-up and sign-in. This configuration will enable the issuance of access tokens and ID tokens.
    • In the Azure portal, go to your Azure Function App. In the "Authentication" section, click on "Add identity provider." Select "Azure Active Directory" and configure it to connect to your Azure AD B2C tenant. You will need to enter the required information, including the tenant ID and application ID.
    • Make sure your Azure Function is configured to accept tokens from Azure AD B2C. This usually requires setting the Audience in your Azure Function's authentication settings to correspond with the application ID of your Azure AD B2C application.
    • Azure Functions will automatically validate the tokens issued by Azure AD B2C, provided that the authentication is set up correctly.
    • Additionally, you can implement further checks in your function code to verify the token claims as necessary. After completing the configuration, test your Azure Function by signing in using your Azure AD B2C user flows to ensure that the access tokens are accepted and verified correctly.

    Also, for your better understanding, please refer to the following documentations:

    Create a REST API for a token issuance start event in Azure Functions

    Authentication and authorization in Azure App Service and Azure Functions

    I hope this helps! Let me know if you have any further questions or need additional assistance.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.