如何在http触发链接中同时获取名称和blob名称?

问题描述 投票:0回答:1

目前我正在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

python azure azure-functions azure-blob-storage azure-http-trigger
1个回答
0
投票

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

我敢打赌这就是让你搞砸的原因。

© www.soinside.com 2019 - 2024. All rights reserved.