Azure / Azure/azure-cli

`az apim api import`: add Parameter `translateRequiredQueryParameters`

Open
#29,081 3 comments 2 reactions 0 assignees View on GitHub
act-observability-squad API Management Auto-Assign customer-reported Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Related command**
```az apim api import```

**Is your feature request related to a problem? Please describe.**
In Azure Api Management, during the import of an OpenApi spec, by default, required query parameters get translated to template parameters. (see https://learn.microsoft.com/en-us/azure/api-management/api-management-api-import-restrictions#api-management-during-openapi-import)

Which leads an API imported that way to return unexpected status codes when the required parameters are missing (the issue is documented here: https://learn.microsoft.com/en-us/answers/questions/829259/apim-returning-404-when-mandatory-query-parameter)

To prevent this behaviour and import the query parameters as query parameters, the Rest API provides the property `translateRequiredQueryParameters`, which can be set to `query`. (see https://learn.microsoft.com/en-us/rest/api/apimanagement/apis/create-or-update?view=rest-apimanagement-2022-08-01&tabs=HTTP#translaterequiredqueryparametersconduct).

Unfortunately, the corresponding azure cli command `az apim api import` does not seem to provide any way to set the above mentioned property, so you are currently stuck with the default behaviour, when using azure cli.

**Describe the solution you'd like**
I would like an additional parameter `translateRequiredQueryParameters` for the `az apim api import` command to be able to control the behaviour during the import. The parameter should map to the already existing property in the Rest Api (see above).

examples:
```bash
# Tell the API Management to keep the required query params as query params
az apim api import --translateRequiredQueryParameters=query ...

# Tell the API Management to translate the required query params to template parameters
az apim api import --translateRequiredQueryParameters=template ...

# If the parameter is not explicitly set, the default behaviour should still be template to be backwards compatible
az apim api import ...
```

**Describe alternatives you've considered**
* We considered using the REST API directly instead of the azure cli but that would be a complete paradigm shift in our devops processes.
* An alternative would also be to not mark any query parameters as `required` in the OpenApi spec, even if they actually are, but that would create a delta between the API description and the actual implementation

**Additional context**
Since this is a behaviour very specific to Azure API Management which is not really to be expected, I think its vital to provide a way to change the default behaviour, regardless if the API was imported through UI, REST Api or Azure cli.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.