使用 python 在 Azure Functions 中进行路由

Adi*_*udi 5 python http azure-functions

我知道我可以使用 Azure 函数中的查询参数来获取值

"myfunction?p=one&p2=two"
Run Code Online (Sandbox Code Playgroud)

我指的是这个问题

如何在 Azure Functions 中进行路由?

但是它只解决 C# 和 node.js,我想获取遵循 Flask 样式的值

/function/<name>/<id>
Run Code Online (Sandbox Code Playgroud)

我可以直接访问,如何在 Azure 函数中的 python 中执行此操作

我还参考了这个文档,它只讨论了node.js和C#

https://github.com/Azure/azure-functions-host/wiki/Http-Functions

Duc*_*ang 8

您可以在文件中添加“route”function.json来更改路径,例如:

"bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "post"
      ],
      "route": "contact/{version}/certificate"
    }
    ....
    ]
Run Code Online (Sandbox Code Playgroud)

在文件中__init__.py,你可以version通过version = req.route_params.get('version')