API Management-API operation policies using Azure CLI

NP 31 Reputation points
2021-01-08T15:39:21.777+00:00

Hi,

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.

Thanks!

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,782 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 68,746 Reputation points
    2021-01-11T04:42:59.967+00:00

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful