Reputation: 1045
I would like to ask about the possibility of achieving consistency in our API Management endpoints by importing all of the functions from our function apps. This would allow us to have a single source of truth for all of our endpoints and ensure that our functions are being utilized in the most efficient manner. Can you provide any insights or recommendations on how to achieve this?
More details: Currently we have many function apps developed with C# .NET Core resides in azure portal.
function app 1 -> All user related functions
function app 2 -> All user services related functions
function app 3 -> All user appointment related functions
If APIM Host Name: https://dev-contoso-apim.azure-api.net
Our approach is to import each function app as an API in API Management, with multiple operations. we have a dedicated set of prefix endpoints planned for each function app.
function app 1 -> All user related functions -> api/v1.0/profiles
function app 2 -> All user services related functions -> api/v1.0/services
function app 3 -> All user appointment related functions -> api/v1.0/appointments
Expected base endpoint for API Management,
All user related functions -> https://dev-contoso-apim.azure-api.net/api/v1.0/profiles
All user services functions -> https://dev-contoso-apim.azure-api.net/api/v1.0/services
All user appointments functions -> https://dev-contoso-apim.azure-api.net/api/v1.0/appointments
I tried with POC with various ways and ended up with a lot of issues on how to manage prefix in API Management and function route.
Below are few options I tried and not working as expected. Example for user appointments available dates API,
Expected APIM endpoint:
Option1: I set function Api Route in C# as Route = "v1.0/appointments/availableDates/"
as and set APIM prefix URL empty , API Management endpoint is not an expected one but API is successfully working.
Actual APIM Endpoint:
Notice /api
is not existed in actual APIM endpoint.
Option2: 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.
Query: I don't want APIM prefix URL to supply as in future If i requires V2 version , I cannot add new function at server side with same route.
Option3: If I set Route for function Api in C# as "v1.0/appointments/availableDates/"
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?
Upvotes: 1
Views: 59
Reputation: 6484
I also have created three function apps and have imported to APIM in the following way-
api/v1.0/profiles
while importing the first function app.So the Base URL will be https://{apim-name}.azure-api.net/api/v1.0/profiles
. But all the operations will have their own URL template which will get amended to the Base URL while accessing that operation. URL template acts as route parameter which we use in Azure functions.
Having /Function1
as route value, my endpoint will be https://{apim-name}.azure-api.net/api/v1.0/profiles/Function1
for GET operation.
api/v1.0/services
API suffix successfully.I am getting expected output upon accessing it.
In this way, you can add the third API as well with api/v1.0/appointments as API suffix. But you can't have exactly same API suffix for two APIs, APIM doesn't allows it.
Upvotes: 0