How to authenticate system assigned manage identity of APIM to App service with AAD protected ?

Bhargav Pasarla 120 Reputation points
2023-08-30T09:22:57.3933333+00:00

I have one App service protected with AAD. There is .net core web api hosted inside this app service.

User's image

I have APIM with System assigned manage identity-

User's image

App service is being hosted at APIM and when I test that i get 401 error -

User's image

I need to configure managed identity of APIM to backend app service so that I can successfully call it.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,450 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,952 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 29,266 Reputation points
    2023-08-30T10:58:19.2866667+00:00

    Hi Bhargav Pasarla Thanks for reaching out. Please confirm if you have configured all the steps mentioned below.

    Enable system-assigned managed identity for your APIM instance. You can do this by going to the "Identity" blade of your APIM instance in the Azure portal and turning on the "System assigned" option.

    Grant the managed identity of your APIM instance access to your AAD-protected App Service. You can do this by adding the managed identity of your APIM instance as a "Contributor" or "Owner" to the App Service's access control (IAM) list.

    To configure Azure RBAC access:

    1. In the left menu, select Access control (IAM).
    2. On the Access control (IAM) page, select Add role assignment.
    3. On the Role tab, select the appropriate role under privileged administrator role.
    4. On the Members tab, select Managed identity > + Select members.
    5. On the Select managed identity page, select the system-assigned managed identity or a user-assigned managed identity associated with your API Management instance, and then select Select.
    6. Select Review + assign. In your App Service, enable AAD authentication by going to the "Authentication / Authorization" blade and turning on the "App Service Authentication" option. Choose the authentication provider. Reference:https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-use-managed-service-identity#supported-scenarios-using-system-assigned-identity
    7. API in APIM should be updated with policy authentication-managed-identity. https://learn.microsoft.com/en-us/azure/api-management/authentication-managed-identity-policy <authentication-managed-identity resource="AD_application_id"/> <!--Application (client) ID of your own Azure AD Application-->

    With these steps, your App Service should be able to authenticate with AAD using the system-assigned managed identity of your APIM instance.

    Let me know even after this if you're facing this error.

    0 comments No comments

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.