gpt4 book ai didi

python - 在 python 中创建 Azure TimerTrigger 持久函数

转载 作者:行者123 更新时间:2023-12-02 23:12:49 31 4
gpt4 key购买 nike

正如我在标题中所说,是否可以有一个使用 TimerTrigger 而不仅仅是 httpTrigger 触发的 azure 持久应用程序?我在这里看到https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-python-vscode这是一个关于如何使用 HttpTrigger 客户端实现它的非常好的示例,如果可能的话,我希望有一个关于如何使用 TimerTrigger 客户端实现它的 Python 示例。

感谢任何帮助,提前致谢。

最佳答案

只要关注启动函数就可以了:

__init__py

import logging

import azure.functions as func
import azure.durable_functions as df


async def main(mytimer: func.TimerRequest, starter: str) -> None:
client = df.DurableOrchestrationClient(starter)
instance_id = await client.start_new("YourOrchestratorName", None, None)

logging.info(f"Started orchestration with ID = '{instance_id}'.")

function.json

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

关于python - 在 python 中创建 Azure TimerTrigger 持久函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65232272/

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