Azure Python 函数:下划线在路由中不起作用
Azure Python Function: Underscore are not working in routes
你好,我正在创建一个“Azure Python 函数”,在 UNC 路径中有一个 POST/GET 路由,例如 http://localhost:7071/api/indicator/sjz_jb_1。因此,我创建了以下代码:
function.json
在之前的版本中我使用了{indicator:alpa?}
基于https://docs.microsoft.com/nl-nl/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=python#customize-the-http-endpoint. But with the alfa datatype the underscores are not working. After searching on the internet I found the Whosebug post Underscore in URL not working with attribute routing它是基于c#但是代码仍然有效但仍然导致找不到页面。
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
],
"route": "indicator/{indicator:regex(^[a-zA-Z_]+$)}"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
init.py
import logging
import json
import azure.functions as func
from shared_code.Metadata import Visualisatieportal_indicatoren
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
ind = req.route_params.get('indicator')
logging.info(ind)
indicator1 = Visualisatieportal_indicatoren.getVisualisatieportal_indicatoren(ind)
result = json.dumps(indicator1.__dict__)
return func.HttpResponse(str(id))
我的问题是,我需要更改什么才能在端点的路由中支持 so 下划线。
曼尼谢谢
埃里克
My question is, what do I need to change so the so underscores can
support in the route of the endpoints.
其中一种解决方法可以解决上述问题,
要使用下划线,您可以尝试以下操作:
"route": "indicator/{indicator:regex(^[a-zA-Z0-9_]*$)}"
此外,基于此 MS DOC
我们不能在 python 函数 中使用以下 attribute
除了 c# & java.
你好,我正在创建一个“Azure Python 函数”,在 UNC 路径中有一个 POST/GET 路由,例如 http://localhost:7071/api/indicator/sjz_jb_1。因此,我创建了以下代码:
function.json
在之前的版本中我使用了{indicator:alpa?}
基于https://docs.microsoft.com/nl-nl/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=python#customize-the-http-endpoint. But with the alfa datatype the underscores are not working. After searching on the internet I found the Whosebug post Underscore in URL not working with attribute routing它是基于c#但是代码仍然有效但仍然导致找不到页面。
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
],
"route": "indicator/{indicator:regex(^[a-zA-Z_]+$)}"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
init.py
import logging
import json
import azure.functions as func
from shared_code.Metadata import Visualisatieportal_indicatoren
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
ind = req.route_params.get('indicator')
logging.info(ind)
indicator1 = Visualisatieportal_indicatoren.getVisualisatieportal_indicatoren(ind)
result = json.dumps(indicator1.__dict__)
return func.HttpResponse(str(id))
我的问题是,我需要更改什么才能在端点的路由中支持 so 下划线。
曼尼谢谢 埃里克
My question is, what do I need to change so the so underscores can support in the route of the endpoints.
其中一种解决方法可以解决上述问题,
要使用下划线,您可以尝试以下操作:
"route": "indicator/{indicator:regex(^[a-zA-Z0-9_]*$)}"
此外,基于此 MS DOC
我们不能在 python 函数 中使用以下 attribute
除了 c# & java.