azure - 持久 Azure Functions 是否可以跨编程语言(C# 到 Python Azure Functions)进行通信?

标签 azure azure-functions azure-sql-database

我有两个 Azure Function 应用,一个是用 C# 创建的,一个是用 Python 创建的。 C# 应用程序通过 API 调用获取 json 文件,并将这些文件放入 Azure Blob 存储容器中。随后,Python Azure Function 通过 ETL 的计时器触发器激活,从 Blob 存储中获取文件,操作 Python pandas 中的数据,然后将数据推送到 Azure SQL 数据库。

我想知道是否有更有效的方法来使用耐用功能来完成此过程。是否可以编排 C# 应用程序使用 Durable Functions 与 Python 应用程序进行通信,以便近乎实时地处理文件,而不是依赖计时器触发器?此外,随着我​​的用户群的增长,这种方法是否可以长期持续,或者我是否应该考虑其他解决方案,例如 Azure Batch、逻辑应用或 Azure 服务总线?

最佳答案

是的,您可以使用 Function chaining pattern在持久函数中执行此操作,因为它仅依赖于同一函数应用程序中的函数并使用函数名称。

但是,您可以通过使用事件网格触发器来设置第二个函数(当前由计时器触发),从而在不使用持久函数的情况下实现最终目标。

Azure Event Grid allows you to easily build applications with event-based architectures. First, select the Azure resource you would like to subscribe to, and then give the event handler or WebHook endpoint to send the event to. Event Grid has built-in support for events coming from Azure services, like storage blobs and resource groups. Event Grid also has support for your own events, using custom topics.

是的,您可以使用 Blob 存储触发器,但这些 do not scaleuse a polling mechanism在幕后,如 this video 中所述,其中事件(来自事件网格)使用推送机制。

  • 查看示例源代码的视频说明。

来自官方文档:

事件网格触发器还具有对 blob 事件的内置支持。对于以下场景,请使用事件网格而不是 Blob 存储触发器:

Blob-only storage accounts: Blob-only storage accounts are supported for blob input and output bindings but not for blob triggers.

High-scale: High scale can be loosely defined as containers that have more than 100,000 blobs in them or storage accounts that have more than 100 blob updates per second.

Minimizing latency: If your function app is on the Consumption plan, there can be up to a 10-minute delay in processing new blobs if a function app has gone idle. To avoid this latency, you can switch to an App Service plan with Always On enabled. You can also use an Event Grid trigger with your Blob storage account. For an example, see the Event Grid tutorial.

本质上,您需要针对您的存储帐户配置事件网格订阅 - 有一个指南 here ,您可以使用概述的语法 here 过滤到某些容器和虚拟目录。 :

To match events from blobs created in specific container sharing a blob name prefix, use a subjectBeginsWith filter like:

/blobServices/default/containers/containername/blobs/blobprefix

我还发现了this post设置此功能时非常有帮助。

关于azure - 持久 Azure Functions 是否可以跨编程语言(C# 到 Python Azure Functions)进行通信?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64233695/

相关文章:

Azure VM,即使未分配给 NSG - ARM 模型也能够使用 RDP

azure - 通过应用程序见解发出有关 Azure 功能错误的通知/警报

sql-server - 如何从 Azure SQL 调用 Webservice/CLR 函数

azure - Azure 中通配符 SSL 证书续订的最佳实践(已固定移动应用程序)

Azure 函数调用 native C++

适用于 Xamarin.forms "Safari cannot open the page because the address is invalid"的 Azure AD B2C?

Azure 表存储和触发器函数

c# - Azure 函数中没有 GetQueryNameValuePairs 的定义

powershell - azure VM中未加载指定的模块 'SQLPS'

sql-server - Azure 数据工厂中的 CDC 支持