擅长:python、mysql、java
<p>为了补充@Ari的好答案,这里的代码将数据从客户端函数(本例中为HTTP请求)一直传递到活动函数:</p>
<p><code>Client -> Orchestrator -> Activity</code></p>
<p>客户</p>
<pre><code>async def main(req: func.HttpRequest, starter: str) -> func.HttpResponse:
client = df.DurableOrchestrationClient(starter)
req_data = req.get_json()
img_url = req_data['img_url']
payload = {"img_url": img_url}
instance_id = await client.start_new(req.route_params["functionName"], None, payload)
logging.info(f"Started orchestration with ID = '{instance_id}'.")
return client.create_check_status_response(req, instance_id)
</code></pre>
<p>编曲</p>
<pre><code>def orchestrator_function(context: df.DurableOrchestrationContext):
input_context = context.get_input()
img_url = input_context.get('img_url')
some_response= yield context.call_activity('MyActivity', img_url)
return [some_response]
</code></pre>
<p>活动</p>
<pre><code>def main(imgUrl: str) -> str:
print(f'.... Image URL = {imgUrl}')
return imgUrl
</code></pre>