7

In azure functions we create the function route / name, but it Always preceded by /api

on the documentation we read:

Note that you did not include the /api base path prefix in the route template, as this is handled by a global setting.

But, How to change this base "/api" path ?

Tony
  • 16,527
  • 15
  • 80
  • 134

2 Answers2

31

Accepted answer does not work for v2 anymore (source: Azure-Functions-Host Gitub repo). For v2 you need to wrap http settings inside extensions object. Working host.json example:

{
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": "customPrefix"
    }
  }
}
truongx
  • 410
  • 4
  • 5
  • 2
    Note that the Azure Portal "test" functionality still seems to read the routePrefix from the original spot, so I ended up having to put it in both places... – goofballLogic Sep 18 '18 at 11:39
  • hi @goofballLogic, your comment saved my day! I kept testing it using portal test feature which throws error 404! How did you update it for Test? i coudn't find the place where i can update. – Preeti Joshi Nov 22 '18 at 10:29
  • @PreetiJoshi I just manually updated host.json file to have "http" both inside "extensions" and also at the top level – goofballLogic Nov 27 '18 at 14:27
4

You are looking for the routePrefix specified in the host.json:

{
  "http": {
    "routePrefix": "whatever"
  }
}

You can set this for example using kudu:

https://<YOURSITE>.scm.azurewebsites.net/DebugConsole/?shell=powershell

Navigate to site -> wwwroot and edit the host.json


Note: This does not work for v2. Please use the answer from truongx instead.

Martin Brandl
  • 56,134
  • 13
  • 133
  • 172