如何更改基本的"/api"功能(v2)上的路径? [英] How to change the base "/api" path on Azure Functions (v2)?

查看:281
本文介绍了如何更改基本的"/api"功能(v2)上的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在azure函数中,我们创建函数route/name,但始终在/api之前

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

文档中阅读:

请注意,您没有在路由模板中包含/api基本路径前缀,因为这是由全局设置处理的.

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

但是, 如何更改此基本"/api"路径?

推荐答案

您正在寻找在 host.json 中指定的 routePrefix :

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

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

您可以使用kudu进行设置,例如:

You can set this for example using kudu:

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

导航到site -> wwwroot并编辑host.json

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

注意:此不适用于v2 .请改用truongx的答案.

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

这篇关于如何更改基本的"/api"功能(v2)上的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆