【发布时间】:2021-08-26 03:36:16
【问题描述】:
我是 Azure 的新手。我需要 http 触发函数来对我的 blob 存储执行一些简单的操作。这将是 datafactory 中管道的一部分,但首先我需要弄清楚如何通过函数编辑 blob。我现在被困住了,因为我不知道我可以使用哪些 API/方法。感谢您的帮助。以下是我的部分代码。
def main(req):
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
requested_file = requests.get("web address")
### Should I connect to blob here?
with open("file.txt", "wb") as file:
file.write(requested_file.content)
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
【问题讨论】:
-
@Thomas 部分是的。但是我该如何做反向 - 下载文件并将其保存到 blob?
-
从哪里下载文件?
-
@Thomas 通过请求库从 Internet 下载文件(例如一些 .csv 或 txt 文件)。然后将其保存在 blob 上。
标签: python azure azure-functions