【问题标题】:How to download/save file to blob starage via azure app functions?如何通过 azure 应用程序功能将文件下载/保存到 blob 存储?
【发布时间】: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
        )

【问题讨论】:

标签: python azure azure-functions


【解决方案1】:

您可以使用Python SDK

或使用bindings and triggers for Azure Functions

您将如何做到这一点是使用绑定来拉入您的 blob,然后使用绑定写出您的 blob。这其实是一个漂亮的good example of it:

与 SDK 类似,您要确保您正在调用和写出。确保您的所有密钥都是正确的,并且您的容器也是正确的!

【讨论】:

    猜你喜欢
    • 2019-11-05
    • 2020-09-21
    • 2017-10-26
    • 2020-08-25
    • 2021-09-20
    • 1970-01-01
    • 2020-11-11
    • 2018-04-25
    • 1970-01-01
    相关资源
    最近更新 更多