How to remove api word from Azure url function

When you create an API launched by Http, the Azure function places it on

https://[function-app-name].azurewebsites.net/api/[Route-configured-in-application]

Is there any way to get rid of the api term from the url and make it look like:

https://[function-app-name].azurewebsites.net/[Route-configured-in-application]
+4
source share
2 answers

Found a solution - Edit the host.json file and set the routePrefix parameter to an empty line:

{
  "http": {
    "routePrefix": ""
  }
}
+8
source

You can also use the capabilities of Azure Function Proxies to do this, which might be better if you want to clearly indicate which methods or routes you want to get.

Just create a file proxy.jsonand add the following JSON fragment to it.

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "myazurefunctionproxy": {
      "matchCondition": {
        "methods": ["GET"],
        "route": "/{slug}"
      },
      "backendUri": "https://%WEBSITE_HOSTNAME%/api/{slug}"
    },
  }
}

This sample redirects all GET requests to a route with a prefix /api/.

+3
source

Source: https://habr.com/ru/post/1689327/


All Articles