python - 如何将多个参数传递给 Azure 持久活动函数
问题描述
我的协调器接收到一个有效负载,该有效负载包含需要与其他数据集一起传递给活动函数的指令。
如何将多个参数传递给活动函数?还是我必须将所有数据混合在一起?
def orchestrator_function(context: df.DurableOrchestrationContext):
# User defined configuration
instructions: str = context.get_input()
task_batch = yield context.call_activity("get_tasks", None)
# Need to pass in instructions too
parallel_tasks = [context.call_activity("perform_task", task) for task in task_batch]
results = yield context.task_all(parallel_tasks)
return results
perform_task
活动需要来自的项目和task_batch
用户输入instructions
我在我的 中做某事function.json
吗?
解决方法 不理想,但我可以将多个参数作为单个元组传递
something = yield context.call_activity("activity", ("param_1", "param_2"))
然后我只需要在活动中引用正确的参数索引。
解决方案
似乎没有教科书的方法可以做到这一点。我选择给我的单个参数一个通用名称,例如parameter
or payload
。
然后在编排器中传递值时,我会这样做:
payload = {"value_1": some_var, "value_2": another_var}
something = yield context.call_activity("activity", payload)
然后在活动功能中,我再次解压它。
编辑:一些隐藏的文档似乎表明https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-error-handling?tabs=python
推荐阅读
- c - 我可以强制动态库链接到特定的动态库依赖项吗?
- javascript - 创建中间件全局与本地变量
- html - 将值从 ngFor 内部的元素传递给 Service
- python - Flask-Ask:如何修复“flask.debughelpers.FormDataRoutingRedirect”错误?
- python - 如何将json键转换为小写字母?
- c# - 正则表达式允许 [1-100] 和百分比符号之间的数值
- javascript - React-DatePicker 库组件定制 | 反应
- python - 在 Python 中加速 for 循环
- npm - npm 错误“前缀 -g”不被识别为内部或外部命令?
- html-email - 黑暗模式下的 Outlook 与 CSS 混淆