Search code examples
azureazure-functionsazure-api-management

After importing an Azure Function app into API Management service, how do I view/edit the policy adding the generated host key authorizing calls?


I have imported an Azure Function app into Azure API Management service, which automatically generates a host key on the Function app for authorizing calls against it.

I would like to inspect the associated policy (if one exists) and edit it, but I can't find it anywhere - it's not shown in "Policy fragments".

How can I view/edit the policy that adds the generated function key to calls against the Function app?

enter image description here

enter image description here


Solution

    • Navigate to any operation which got added post importing a Function App in APIM. Lets say, in my case its HttpTrigger1. Then, click on Inbound processing policies --> </>.

    enter image description here

    • This will give you below policy.
    <policies>
        <inbound>
            <base />
            <set-backend-service id="apim-generated-policy" backend-id="afreeen-fa" />
        </inbound>
        <backend>
            <base />
        </backend>
        <outbound>
            <base />
        </outbound>
        <on-error>
            <base />
        </on-error>
    </policies>
    
    • This policy signifies that, the operation is referring to a backend Id afreeen-fa which is created in APIs --> Backends blade of APIM instance.

    enter image description here

    • Click on the backend name and then navigate to Authorization credentials to access the x-function-key which is being passed in request header when you invoke an operation in APIM test console.

    • This is how APIM is storing the function key after importing a function app and using it via set-backend-service policy.

    enter image description here

    enter image description here