【问题标题】:Create Azure TimerTrigger Durable Function in python在 python 中创建 Azure TimerTrigger 持久函数
【发布时间】:2020-12-10 09:59:33
【问题描述】:

正如我在标题中所声称的,是否有可能拥有一个使用 TimerTrigger 而不仅仅是 httpTrigger 触发的天蓝色耐用应用程序? 我在这里看到https://docs.microsoft.com/en-us/azure/azure-functions/durable/quickstart-python-vscode 一个很好的例子,说明如何使用 HttpTrigger 客户端实现它,如果可能的话,我想在 python 中提供一个关于如何使用 TimerTrigger 客户端的例子。

任何帮助表示感谢,在此先感谢。

【问题讨论】:

  • 嗨,有更新吗?你试过我的答案吗?

标签: python azure azure-functions azure-durable-functions


【解决方案1】:

只关注启动功能就可以了:

__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"
    }
  ]
}

【讨论】:

  • 感谢您的回复!这几乎就是我所做的......看到你的回答我想我可以省略req:'func.HttpRequest'以及关于http的那些东西?我正在寻找仅使用 CRON 时间表触发的 smt。主要将只包含这样的两行? client = df.DurableOrchestrationClient(starter) instance_id = await client.start_new("MyOrchestrator", None, None)
  • @SalvatoreNedia 只需更改启动功能触发器即可。
猜你喜欢
  • 1970-01-01
  • 2020-10-27
  • 2021-12-05
  • 1970-01-01
  • 1970-01-01
  • 2021-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多