我知道我可以在 Azure 函数中使用查询参数来获取值
"myfunction?p=one&p2=two"
我指的是这个问题
但是它只针对 C# 和 node.js,我想获取以下 flask 样式的值
/function/<name>/<id>
我可以直接访问,我如何在Azure函数中的python中做到这一点
我还引用了这个文档,它只讨论了 node.js 和 C#
https://github.com/Azure/azure-functions-host/wiki/Http-Functions
最佳答案
你可以在function.json
文件中添加“route”来改变路径,例如:
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post"
],
"route": "contact/{version}/certificate"
}
....
]
在文件 __init__.py
中,
您可以通过 version = req.route_params.get('version')
version
关于python - 使用 python 在 Azure Functions 中进行路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52446199/