Azure Front Door - Path based routing rule
We see how can we configure the path based routing
using azure front door service within 2 different versions on API. These 2 API
are hosted in 2 different azure web app.
I have created 2 web api and hosted the default weather
forecast api with core 3.1 with one more entity called version to identify the
api version.
Version one api output

Version two api output
Version one api output
Version two api output
Along with it I have added the version in the route of
version 2 api as below
[Route("V2/[controller]")]


I have furnished the steps below to achieve the simple Path based routing rule
Step 1: Create 2 web app versiononeapi, versiontwoapi.
Step 2: Create a web api project with core 3.1
Step 3: change the response for the get method in WeatherForecastController
as below, make version as V1 and
right click on project Ć
publish Ć
Azure Ć
Azure app service windowsĆ
select the subscription, resource group and web app versiononeapi
Step 4: change the response for the get method in WeatherForecastController
as below, make version as V2 and
right click on project Ć
publish Ć
Azure Ć
Azure app service windowsĆ
select the subscription, resource group and web app versiontwoapi
Step 5: Login to azure portal, search for Front Doors and
click add.
Step 6: Configure the basics by selecting the resource group
where you have the web app
Step 7: Next we do the Configuration for front door service.
Step 8: Click on frontends/domain add button and provide a name
for it, I used versionbasedapirouting. No other changes just add.
Step 9: Now we have to create 2 different pools
1)versiononeapibp Ć add a backend Ć select app service as host type Ć in backend host name select the versiononeapi web app Ć add Ć add
2) versiontwoapibp Ć add a backend Ć select app service as host type Ć in backend host name select the versiontwoapi web app Ć add Ć add
1)versiononeapibp Ć add a backend Ć select app service as host type Ć in backend host name select the versiononeapi web app Ć add Ć add
2) versiontwoapibp Ć add a backend Ć select app service as host type Ć in backend host name select the versiontwoapi web app Ć add Ć add
Step 10: Route rule
1)
versiononeapiroute Ć No change as all our default
routes to versiononeapi, just select the versiononeapibp.
Ć add
2)
versiontwoapiroute Ć in patterns to match replace
the existing /* with /V2/*Ć select
versiontwoapibp Ć add
It would take some 5 to 10 mins to configure after that will
check the result.
https:// versionbasedapirouting.azurefd.net/WeatherForecast
will give version 1 response
https:// versionbasedapirouting.azurefd.net/V2/WeatherForecast
will give version 2 response
Comments
Post a Comment