如何通过azure应用程序功能下载/保存文件到blob存储?



我是Azure的新手。我需要http触发函数在我的blob存储上执行一些简单的操作。这将是数据工厂管道的一部分,但首先我需要弄清楚如何通过函数编辑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
)

您可以使用Python SDK

或者为Azure Functions使用绑定和触发器

你将如何做到这一点是使用绑定拉入你的blob,然后使用绑定写出你的blob。这是一个很好的例子:

与SDK类似,您希望确保您正在调用和写入。确保你所有的钥匙和容器都是正确的!

最新更新