API Management-API operation policies using Azure CLI

NP 26 Reputation points


I have few function apps that have been registered under APIM. And all the APIs in APIM would need 'Ocip-Apim-Subscription-Key' while accessing them. Addition to subscription-key, function code/key should also be provided to access. Therefore, while consuming apim apis, both 'Ocip-Apim-Subscription-Key' and 'x-functions-key' should be provided in header. But passing both keys is a overhead, so I have defined x-functions-key in inbound policy (Add Policy -> Set Headers). This works as expected and no need to pass x-functions-key by the consumers anymore.

I have added the inbound set-header policy through Azure portal. However, I would like to add the same using azure CLI command (ex: az apim api operation update.....). I have tried using --add parameter (az apim api operation. update...... --add policies) but unable to get it's syntax or usage. Also there is no exact document/samples describe this use-case.

Please let me know if there are any samples/documentation on achieve this using CLI command.


Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,084 questions
No comments
1 vote

Accepted answer
  1. MayankBargali-MSFT 49,711 Reputation points Microsoft Employee

    Hi @NP

    Welcome to Microsoft Q&A! Thanks for posting the question.

    Currently, az CLI doesn't support this yet, you could use Az.ApiManagement PowerShell Module instead. To add the policy you can use Set-AzApiManagementPolicy cmdlet.

    Also, feel free to create a feature request to add support for updating policies using the az cli.

0 additional answers

Sort by: Most helpful