简体   繁体   English

如何使用 Azure 数据工厂执行长时间运行的持久 Azure 函数?

[英]How to execute long running durable Azure Functions with Azure Data Factory?

My problem:我的问题:

  1. I have Azure Data Factory (ADF) calling Azure Function(Python) with HTTP trigger.我有 Azure 数据工厂 (ADF) 使用 HTTP 触发器调用 Azure 函数 (Python)。
  2. ADF provides parameters to Function by json. ADF通过json向Function提供参数。
  3. Function processing takes over 230 seconds and timeout occurs Function 处理超过230秒超时
  4. Azure Factory get timeout errors: Azure 工厂获取超时错误:

Solution idea:解决思路:

Question?问题? A) If ADF calls HTTP Starter max 230 timeout occurs? A) 如果 ADF 调用 HTTP 启动器最大 230 超时发生? Or this has no max time limit?或者这没有最大时间限制? B) How to make Durable Function to return value to ADF. B) 如何使 Durable Function 返回值给 ADF。 (I would next request complete status with next ADF activity) (接下来我将请求下一次 ADF 活动的完整状态)

As per the official Microsoft document , Azure Functions times out after 230 seconds regardless of the functionTimeout setting you've configured in the settings.根据Microsoft 官方文档无论您在设置中配置的functionTimeout设置如何,Azure Functions 都会在 230 秒后超时。 The solution for this is to make it a background work with Durable Functions.解决方案是使用 Durable Functions 使其成为后台工作。

Durable Functions are running on the same platform as normal Azure Functions, but they run asynchronously.持久函数与普通 Azure 函数在同一平台上运行,但它们异步运行。 When you trigger a Durable Function, it creates a background process and gives you a few URLs that you can interact with that process;当您触发 Durable Function 时,它会创建一个后台进程并为您提供一些可以与该进程交互的 URL; including one to query its status.包括一个查询其状态。 When you call it, it returns the status of the background job as well as the data if it's finished.当您调用它时,它会返回后台作业的状态以及完成时的数据。

The idea is to trigger a Durable Function through an HTTP endpoint, wait for it to finish and then get the result.这个想法是通过 HTTP 端点触发一个 Durable Function,等待它完成然后得到结果。 Here's how it looks like:它是这样的:

在此处输入图像描述

And here's how it looks inside the Until activity:下面是它在 Until 活动中的样子:

在此处输入图像描述

Please follow the below steps:请按照以下步骤操作:

  1. First, we trigger our Durable Function through an HTTP trigger using Azure Function activity.首先,我们使用 Azure Function 活动通过 HTTP 触发器触发我们的持久 Function。

  2. Then with the Until activity, we check status of that function.然后通过 Until 活动,我们检查 function 的状态。

    • The Wait activity waits around 30 seconds (or different, up to you) to let function to be executed Wait 活动等待大约 30 秒(或不同,取决于您)让 function 被执行

    • The Web activity makes a request to the statusQueryUrl that Azure Function activity returns, by calling @activity('StartUntar').output.statusQueryGetUri Web 活动通过调用@activity('StartUntar').output.statusQueryGetUri向 Azure Function 活动返回的 statusQueryUrl 发出请求

  3. Until activity checks the result of CheckStatus Web activity with expression @not(or(equals(activity('CheckStatus').output.runtimeStatus, 'Pending'), equals(activity('CheckStatus').output.runtimeStatus, 'Running'))) . Until activity 用表达式检查 CheckStatus Web activity 的结果@not(or(equals(activity('CheckStatus').output.runtimeStatus, 'Pending'), equals(activity('CheckStatus').output.runtimeStatus, 'Running' )))

  4. It repeats until the function is finished or failed, or until it times out (set on the Timeout property).它会重复,直到 function 完成或失败,或者直到超时(在 Timeout 属性上设置)。

I would recommend you use the Webhook activity in ADF and have your durable function perform a callback upon completion (success or failure) to the callback URI.我建议您在 ADF 中使用Webhook 活动,并让持久的 function 在完成(成功或失败)后执行回调 URI。 That should be less expensive in ADF than looping for an extended period of time.在 ADF 中,这应该比长时间循环更便宜。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM