目前我正在azure函数中进行http触发,我能够成功触发该函数。下面是我的代码部分http触发器。
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
# Retrieve the blob name from the HTTP request
blob_name = req.params.get('blob_name')
if not blob_name:
return func.HttpResponse(
"Please provide a 'blob_name' parameter in the query string.",
status_code=400
)
在这里,我正在获取 blob_name 将我的文件放入容器内,该文件工作正常,但我需要做的是我想同时获取“name”和“blob_name”参数,可以这样做吗?除了 get() 函数之外,任何其他可用函数都可以执行此操作。 默认函数 url -
https://functionappname.azurewebsites.net/api/http_trigger?blob_name=file.txt
现在我想要这样的
https://functionappname.azurewebsites.net/api/http_trigger?blob_name=file.txt+name=user01
req.params
是 dict
;您可以在其上执行 .get()
来检索元素 - 您可以检索 name
,就像您当前使用 blob_name
所做的那样。
但是:您的网址格式错误;您需要使用
+
来代替 &
来分隔连续的参数。
而不是
https://functionappname.azurewebsites.net/api/http_trigger?blob_name=file.txt+name=user01
https://functionappname.azurewebsites.net/api/http_trigger?blob_name=file.txt&name=user01
我敢打赌这就是让你搞砸的原因。