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

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

问题描述

在 azure 函数中,我们创建函数路由/名称,但它总是以/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:

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

您可以使用 kudu 进行设置:

You can set this for example using kudu:

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

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

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

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

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

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