如何将列表发送到Azure耐用功能

发布于 2025-02-09 11:49:59 字数 563 浏览 2 评论 0 原文

我有一个具有两个Python函数的体系结构:ListCreator()和Activity()。 ListCreator()函数由HTTP触发器触发,并生成字符串列表。我想将此字符串列表传递给编排函数,并多次调用Activity()函数。

我该如何将其传递给编排者?我还需要在Microsoft文档中使用的启动功能吗?

我的代码的过度简化版本看起来像这样:

listCreator():

import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse
     mylist=['helo','world']

I have an architecture with two python functions: listcreator() and activity(). The listcreator() function is triggered by an http trigger and generates a list of strings. I want to pass this list of strings to an orchestrator function and call the activity() function multiple times.

How do I pass this to the orchestrator? Do I also need a starter function as desribed in the microsoft documents? https://learn.microsoft.com/nl-nl/azure/azure-functions/durable/quickstart-python-vscode

An oversimplified version of my code looks like this:

listcreator():

import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse
     mylist=['helo','world']

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

行雁书 2025-02-16 11:49:59

最好的解决方案可能是将您的 listCreator()函数用作 client> client function (您称为启动器函数)。从 listCreator()中,您可以生成列表并将其传递到 andestrator 。最后,从编排器中,将列表传递到活动函数并运行它。

代码草图:

# inside the client function call the orchestrato
client = df.DurableOrchestrationClient(starter)
instance_id = await client.start_new("yourorchestrator", None,  [1,2,3,4])

#inside orchestrator
data = context.get_input()
context.call_activity("activity", data)

probably the best solution is to use your listcreator() function as Client function (the function you called as starter function). From the listcreator(), you can generate the list and pass it to the orchestrator. Finally from the orchestrator, pass the list to the activity function and run it.

A sketch of code:

# inside the client function call the orchestrato
client = df.DurableOrchestrationClient(starter)
instance_id = await client.start_new("yourorchestrator", None,  [1,2,3,4])

#inside orchestrator
data = context.get_input()
context.call_activity("activity", data)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文