gpt4 book ai didi

python - 时间触发的 Azure 函数不会每分钟触发一次

转载 作者:行者123 更新时间:2023-12-03 06:10:33 25 4
gpt4 key购买 nike

PS:这里完全是初学者。

由于公司政策的一些限制,我无法在本地测试此功能。不过,我能够将该函数部署到我们的函数应用程序中。

我有一个 init.py ,如下所示:

import datetime
import logging

import azure.functions as func


def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()

if mytimer.past_due:
logging.info('The timer is past due!')

logging.info('Hello!!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)

function.json 如下所示:

{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "* * * * *"
}
]
}

我希望日志语句每分钟显示一次,但情况似乎并非如此。输出:Output response

我在这里检查了什么错误?

最佳答案

我创建了一个 Azure Function Timer 触发器,并将 CRON 计划设置为 0 */1 * * * *

我的 function.json:-

{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */1 * * * *"
}
]
}

本地函数每分钟运行一次:-

enter image description here

我在 Azure 门户上部署了该函数,并在执行计时器触发函数的每分钟收到日志。

enter image description here

enter image description here

日志级别设置为详细:-

enter image description here

如果日志未加载,请确保您已为 Function 应用启用 Application Insights:-

enter image description here

日志还存储在使用 Azure Function 应用创建的存储帐户中,请确保组织防火墙或其他限制不会阻止您连接到存储帐户或 Application Insights。如果您连接到任何公司代理或 VPN,请尝试删除限制或在 VNet 内部署您的函数应用程序,并允许存储帐户和您的防火墙 IP 访问函数应用程序,有关使用 Vnet 的 Azure Functions 的详细信息,请参阅 How to configure Azure Functions with a virtual network | Microsoft Learn

另外请参阅SO thread answers如果您的功能日志未正确加载。

关于python - 时间触发的 Azure 函数不会每分钟触发一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76849605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com