Azure 函数 - 使用 python 记录到 Azure blob

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

我有一个 Azure 函数,我尝试了多种写入/记录方式,我的 python 脚本记录到 Azure blob。 然而,我似乎无法让它工作,即使文档导致了死胡同。

这个问题之前已经问过,但有点过时了。

azure-storage-logging 包似乎也被遗弃了。

这是我用于测试不同方法的一些示例代码:

import logging
import azure.functions as func

app = func.FunctionApp()

@app.schedule(schedule="*/30 * * * *", arg_name="myTimer", run_on_startup=True,
              use_monitor=False) 
def func_demo_timer_trigger(myTimer: func.TimerRequest) -> None:
    if myTimer.past_due:
        logging.info('The timer is past due!')

    logging.info('Python timer trigger function executed.')

如何将此日志消息放入 Blob 中? 此外,每次运行都会有一条日志消息,应将其添加到同一文件中。

(应用见解或相关主题不相关)。

欢迎任何提示和/或小例子。

python azure logging azure-functions
1个回答
0
投票

要将数据从用 Python 编写的 Azure 函数记录到 Azure Blob 存储容器,可以使用 azure-storage-blob 库。

##导入 azure.functions 作为 func ##从 azure.storage.blob 导入 BlobServiceClient、BlobClient、ContainerClient##

确保安装了 azure-functions 和 azure-storage-blob 库

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