Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the word ‘api’ from Azure functions url

When you create an Http triggered API, Azure function hosts it on

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

Is there any way of getting rid of the term api from the URL and make it look like:

https://[function-app-name].azurewebsites.net/[Route-configured-in-application]
like image 773
Mayank Avatar asked Nov 15 '17 16:11

Mayank


People also ask

Can we rename function app in Azure?

The UI does not directly support renaming a Function, but you can work around this using the following manual steps: Stop your Function App. To do this, go under Function app settings / Go To App Service Settings, and click on the Stop button. Note: doing this can lose some historical logging.

What is my Azure function URL?

In order to get the actual URL of the function go to Azure Portal and find your Azure Function resource. Click on it. You will see an overview where your Azure Function Space is defined. Here you could have more than one actual function.

Can I use Azure function as API?

Import an Azure Function App as a new API Follow the steps below to create a new API from an Azure Function App. Navigate to your API Management service in the Azure portal and select APIs from the menu. In the Add a new API list, select Function App.

How do I disable Azure function?

The recommended way to disable a function is with an app setting in the format AzureWebJobs. <FUNCTION_NAME>. Disabled set to true . You can create and modify this application setting in a number of ways, including by using the Azure CLI and from your function's Overview tab in the Azure portal.


3 Answers

The Azure Functions v2 solution is covered in this answer, the http bit needs to be wrapped in an extensions property.

{
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": "customPrefix"
    }
  }
}
like image 118
Denis Pitcher Avatar answered Oct 03 '22 05:10

Denis Pitcher


Edit the host.json file and set routePrefix to empty string:

{
  "http": {
    "routePrefix": ""
  }
}
like image 23
Mayank Avatar answered Oct 03 '22 05:10

Mayank


The accepted answer no longer works if you're using version 2 functions, instead you need to put the http settings in an extensions property:

"extensions": {
    "http": {
        "routePrefix": ""
    }
}

You can get caught out looking at the hosts.json reference because if you only look at the http section it shows just the http properties so make sure to check the start of the doc for the top level hosts.json format.

like image 35
Matt Avatar answered Oct 03 '22 03:10

Matt