Remove the word "api" from HttpTriggered Azure functions url

When you create an Http triggered azure function, it will automatically adds the keyword api in the url and give the url as

https://<function-app-url>.azurewebsites.net/api/<azure-function name="" route-configured-in-application=""></azure-function>

But when someone not using the function as an api, it is inappropriate to use the "api" keyword in it. So to remove the "api" in the url we need to change configure as following in the host.json (You can do it by opening the file using "App Service Editor" or Kudu console)

Version 1.x
{
  "http": {
    "routePrefix": ""
  }
}
Version 2.x
{
  "extensions": {
    "http": {
      "routePrefix": ""
    }
  }
}

With the above setting the azure function url will change as
https://<function-app-url>.azurewebsites.net/<azure-function name="" route-configured-in-application=""></azure-function></function-app-url>

Happy Coding 😊!

Reference: https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json

Gopikrishna

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment