'Using Managed Identity to call APIM endpoint

I am trying to make a call to the APIM endpoint in Azure from the function app using the Managed Identity of the function app. Not sure if there is any article I could take a reference from?



Solution 1:[1]

I believe you can do it using validate-jwt policy. The policy will look like this:

<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
    <openid-config url="https://login.microsoftonline.com/{aad-tenant}/v2.0/.well-known/openid-configuration" />
    <required-claims>
        <claim name="aud">
            <value>{backend-api-application-client-id}</value>
        </claim>
    </required-claims>
</validate-jwt>

more info: https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-protect-backend-with-aad#configure-a-jwt-validation-policy-to-pre-authorize-requests

Solution 2:[2]

You should apply this policy type: https://docs.microsoft.com/en-us/azure/api-management/api-management-authentication-policies#ManagedIdentity

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thiago Custodio
Solution 2 maras2002