Search code examples
asp.net-core-webapiazure-api-managementapi-versioning

Azure API Management - Versioning path schema duplicates version in url


I'm trying to apply api management version sets to query a .Netcore 3.1 web api which has two versions. I have chosen the path schema on the version set, which appends the version identifier to the url. In this case /v1: enter image description here

The thing is that in my api I am also using path schema to version the endpoint on the web api, so when apim builds the url, it appends the apim version identifier to the api version path, which results in a duplicate, like:

https://myapi.com/apiname/v1/v1/endpoint , where v1/endopoint is the path to the controller.

To solve this, I have switched the version schema on the web api to header and created a policy on apim that adds the version header to the request, so that the only version in the path is now the one in apim.

I wanted to know if this is the right way to go or if there is a better solution. Maybe its possible to tell apim to ignore the version /v1 from the path?

Thanks for the help!


Solution

  • APIMs domain model allows one to control versioning scheme (path prefix, header name/value, query parameter name/value) at the level of API version set, so that you do not need to duplicate /v1.0 on every operation of your API. By nature of this if your API version set is configured to have path prefix of /v1.0 it will be appended to all API paths included into this version set. And that is what produces the doubling.