无服务器计算

什么是 Azure 函数?

发布时间: 2024年10月30日

最后更新: 11月 26, 2024

探索 Azure Functions 的多功能性。本指南涵盖其用例、托管选项、优势、持久函数、语言支持以及如何入门。

什么是 Azure 函数?

Azure Function 托管在 Microsoft Azure 上,是一种无服务器计算工具。开发人员利用它来执行代码,而无需管理服务器。各种事件会触发代码运行,这就是为什么它被事件驱动的应用程序所使用。 

Azure Functions has multiple languages and is used for file uploads, web APIs, data stream processing, and other functions based on triggers/binding.

You’ll find Azure Functions within the Azure serverless ecosystem. Integrate it with Event Grid, Logic Apps, and Service to scale cloud apps up or down.

When should I use Azure Functions?

You should use Azure Functions for task scalability based on triggers and events. The tool might be suitable if infrastructure management isn’t your priority, but running code is still necessary. 

Azure Functions is used by solo developers and larger organizations. Events you may need to use the tool within include date changes, timer triggers, and HTTP requests. 

You might also use Azure Functions for system integration/workflow automation. Other use cases are data processing and API-building. Some common scenarios in which you would use Azure Functions are: 

  • Sending emails/notifications and other forms of task automation 
  • 无服务器 API 和微服务构建 
  • 与 Azure 存储、逻辑应用和类似工具集成 
  • Data processing from sensors/IoT devices
提示

Review the Azure Functions Documentation and look at the templates/examples available before using it.

Azure Functions有哪些可用的托管选项?

如果需要基于 Kubernetes 的托管,您可以在 Azure Functions 中使用四种托管功能:消耗计划、高级计划、专用计划和 Kubernetes 事件驱动自动缩放器 (KEDA)。 

定价和功能因每个计划而异,这意味着您需要考虑您的预期工作负载。在做出选择之前,请考虑您对可扩展性和连接性的要求。还必须分析性能、成本和功能。

使用Azure Functions有哪些好处?

无服务器架构 根据需求扩展工作负载,这意味着开发人员可以专注于编码;但是,如果您的需求发生变化,您可能需要不时地更改规则。

You can use Azure Functions with JavaScript, Python, and other programming languages. You can use Azure Functions with other Azure services, but external ones may be utilized instead. Developers use Azure Functions for functions based on various event triggers/data bindings. 

You should also use Azure Functions for testing and deployment while controlling access management via easy-auth. Developers may use Azure Functions on clouds in hybrid environments;您也可以考虑按使用量付费的定价模式。

什么是持久函数?

Durable Functions 是 Azure Functions 的一个扩展。开发人员使用它来创建无服务器的有状态函数。如果您的工作流程运行时间较长、较为复杂,并且可能需要检查点或自动重启,则应使用 Durable Functions。使用 Durable Functions 时,还应考虑状态管理。 

使用 Durable Functions 的编程模型进行有状态工作流程/管理编排。协调多个函数也是您可能需要考虑的问题。Durable Functions 适用于:

  • 审批流程
  • 定期数据处理
  • Human interaction workflows

我可以使用哪些语言来开发 Azure Functions?

Developers can use Azure Functions with PowerShell, Python, Java, TypeScript, C#, JavaScript, and other programming languages. Fully supported and experimental are the two levels you can use.

While fully supported languages have native support that enables you to develop/run functions solely in one language, experimental is more limited and should be used for testing/exploration.

结论

如果您需要无服务器计算,则应考虑使用 Azure Functions;它可以帮助提高可扩展性、效率和成本效益,但您需要考虑不管理服务器的缺点。将 Azure Functions 用于 Web API、事件驱动系统和类似需求。

准备好开始了吗?

We've been where you are. Let's share our 18 years of experience and make your global dreams a reality.
与专家交流
马赛克图像
zh_CN简体中文