Azure API Management APIs endpoint are not displaying as expected

91 views Asked by At

I created a brand new function app and imported to APIM. I tried below option to align with customer expected APIM endpoint for API. But some are working and others are failed.

I really perplexed a lot to define APIM suffix and Function App route url? what are the best consideration and practices to follow?

Does the re-writeurl policy helps in this case?

Expected Customer APIM endpoint:

https://dev-contoso-apim.azure-api.net/api/v1.0/appointments/availableDates/?serviceId=1&branchId=2&startDate=2024-02-01

Function name: dev-contoso-appointments-func

APIM Host: dev-contoso-apim.azure-api.net

Settings of Appointment APIs collection in APIM.

enter image description here

The route for function API is defined at server side as shown in below

enter image description here

Option 1: If I change function api route to Route="availableDates"at server side and add APIM prefix url as api/v1.0/appointments , APIM endpoint is displaying as expected like below and working successfully.

Question: I don't want APIM prefix URL to supply as in future if I require V2 version? Can I still add?

Expected APIM endpoint:

https://dev-contoso-apim.azure-api.net/api/v1.0/appointments/availableDates/?serviceId=1&branchId=2&startDate=2024-02-01

Option 2: If I retain Route = "v1.0/appointments/availableDates/" as it is and set APIM prefix url empty, APIM endpoint is not an expected one but APIM API is successfully working.

Actual APIM Endpoint:

https://dev-contoso-apim.azure-api.net/v1.0/appointments/availableDates/availableTimes/?serviceId=1&branchId=2&startDate=2024-02-01

Expected APIM endpoint:

https://dev-contoso-apim.azure-api.net/api/v1.0/appointments/api/v1.0/appointments/availableDates/?serviceId=1&branchId=2&startDate=2024-02-01

Notice /api does not exist in the actual APIM endpoint.

How do I setup my APIM prefix and route in option 2?

enter image description here

Option3: If I retain Route = "v1.0/appointments/availableDates/" as it is and set APIM prefix url as api, APIM endpoint is an expected one but APIM API is NOT working.

Error: Resource not found.

How do I setup my APIM prefix and route in option 2?

Actual APIM Endpoint:

 https://dev-contoso-apim.azure-api.net/api/v1.0/appointments/availableDates/availableTimes/?serviceId=1&branchId=2&startDate=2024-02-01

Expected APIM endpoint:

https://dev-contoso-apim.azure-api.net/api/v1.0/appointments/api/v1.0/appointments/availableDates/?serviceId=1&branchId=2&startDate=2024-02-01

enter image description here

1

There are 1 answers

7
Ikhtesam Afrin On

I have set the route="v1.0/appointments/availableDates/" in function and imported the function into APIM as shown below-

enter image description here

enter image description here

By adding API URL suffix as api/, endpoint becomes https://{apim-name}.azure-api.net/api/v1.0/appointments/availableDates/?serviceId=1&branchId=2&startDate=2024-02-01. I am able to get the expected output when testing it.

enter image description here enter image description here

Secondly, you can also set the function route to api/v1.0/appointments/availableDates/ and while importing set APIM suffix to empty.

Rewrite URL policy can be used to add query string parameters.

enter image description here