Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 与CosmosDBTrigger一起使用Azure持久函数_Python_Azure_Azure Functions_Azure Function App_Azure Durable Functions - Fatal编程技术网

Python 与CosmosDBTrigger一起使用Azure持久函数

Python 与CosmosDBTrigger一起使用Azure持久函数,python,azure,azure-functions,azure-function-app,azure-durable-functions,Python,Azure,Azure Functions,Azure Function App,Azure Durable Functions,我有一个数据管道,它从CosmosDB读取变更提要,并通过持久函数将数据加载到外部资源中。我的启动函数(在Python中)如下所示: 导入azure.u作为df 将azure.1函数导入为func 异步def main(文档:func.DocumentList,启动器:str): client=df.DurableOrchestrationClient(初学者) 实例\u id=wait client.start\u new('MyDFOrchestrator',client\u input=d

我有一个数据管道,它从CosmosDB读取变更提要,并通过持久函数将数据加载到外部资源中。我的启动函数(在Python中)如下所示:

导入azure.u作为df
将azure.1函数导入为func
异步def main(文档:func.DocumentList,启动器:str):
client=df.DurableOrchestrationClient(初学者)
实例\u id=wait client.start\u new('MyDFOrchestrator',client\u input=documents)
info(f“已启动业务流程ID{instance_ID}”)

但是,这会遇到错误,因为
cosmosDBTrigger
传入一个Cosmos文档列表,但
client.start\u new()
需要一个JSON可序列化的输入值。我可以通过将列表放入一个简单的JSON对象(如
{“doc_list”:[{doc1}、{doc2}、{doc3}]}
)来解决这个问题,但我想确保在API中没有缺少处理此模式的内容。

将JSON作为输入值传递给orchestrator应该没问题。有一个例子与此类似。虽然这个例子使用的是http触发器,但是这里关注的领域与您在启动程序/触发功能中使用的触发器无关

或者,您可以创建一个包含模型/实体结构的具体可序列化类(比原始json干净得多)。要创建可序列化的类,我们只需要类导出两个静态方法:To_json()和from_json()。持久函数框架将内部调用这些类来序列化和反序列化自定义类。因此,您应该设计这两个函数,以便对to_json的结果从_json调用能够重构您的类