Azure Functions 简介An introduction to Azure Functions
Azure Functions 允许你运行小段代码(称为“函数”)且不需要担心应用程序基础结构。Azure Functions allows you to run small pieces of code (called "functions") without worrying about application infrastructure. 借助 Azure Functions,云基础结构可以提供应用程序保持规模化运行所需的所有最新状态的服务器。With Azure Functions, the cloud infrastructure provides all the up-to-date servers you need to keep your application running at scale.
函数由特定类型的事件“触发”。A function is "triggered" by a specific type of event. 支持的触发器包括对数据更改做出响应、对消息做出响应、按计划运行,或者生成 HTTP 请求的结果。Supported triggers include responding to changes in data, responding to messages, running on a schedule, or as the result of an HTTP request.
虽然始终都可直接针对大量服务编写代码,但使用绑定可以简化与其他服务的集成。Although you can always code directly against myriad services, integrating with other services is streamlined by using bindings. 使用绑定,你能够以声明方式访问各种 Azure 服务和第三方服务。Bindings give you declarative access to a wide variety of Azure and third-party services.
功能Features
Azure Functions 的一些主要功能包括:Some key features of Azure Functions include:
无服务器应用程序 :使用 Functions,可在 Azure 上开发无服务器应用程序。Serverless applications : Functions allow you to develop serverless applications on Azure.
语言选择 :使用所选的 C#、Java、JavaScript 和 PowerShell 编写函数。Choice of language : Write functions using your choice of C#, Java, JavaScript and PowerShell.
按使用付费定价模型 :仅为运行代码所用的时间付费。Pay-per-use pricing model : Pay only for the time spent running your code. 请参阅定价部分中的使用托管计划选项。See the Consumption hosting plan option in the pricing section.
自带依赖项 :Functions 支持 NuGet 和 NPM,允许你访问你喜欢的库。Bring your own dependencies : Functions supports NuGet and NPM, giving you access to your favorite libraries.
集成的安全性 :使用 OAuth 提供程序(如 Azure Active Directory 和 Microsoft 帐户)保护 HTTP 触发的函数。Integrated security : Protect HTTP-triggered functions with OAuth providers such as Azure Active Directory and Microsoft Account.
简化的集成 :轻松与 Azure 服务和软件即服务 (SaaS) 产品/服务进行集成。Simplified integration : Easily integrate with Azure services and software-as-a-service (SaaS) offerings.
灵活开发 :直接在门户中编写函数代码,或者通过 GitHub、 Azure DevOps Services 和其他 受支持的开发工具设置持续集成和部署代码。Flexible development : Set up continuous integration and deploy your code through GitHub, Azure DevOps Services, and other supported development tools.
有状态无服务器体系结构 :使用 Durable Functions 协调无服务器应用程序。Stateful serverless architecture : Orchestrate serverless applications with Durable Functions.
开放源代码 :Functions 运行时是开源的, 可在 GitHub 上找到。Open-source : The Functions runtime is open-source and available on GitHub.
使用 Functions 可以做什么?What can I do with Functions?
Functions 是一个理想的解决方案,用于处理批量数据、集成系统、使用物联网 (IoT) 以及生成简单的 API 和微服务。Functions is a great solution for processing bulk data, integrating systems, working with the internet-of-things (IoT), and building simple APIs and micro-services.
有一系列模板可帮助你开始使用关键方案,包括:A series of templates is available to get you started with key scenarios including:
HTTP :基于 HTTP 请求运行代码HTTP : Run code based on HTTP requests
计时器 :将代码安排 在预定义的时间运行Timer : Schedule code to run at predefined times
Azure Cosmos DB :处理 新的和修改的 Azure Cosmos DB 文档Azure Cosmos DB : Process new and modified Azure Cosmos DB documents
Blob 存储 :处理 新的和修改的 Azure 存储 blobBlob storage : Process new and modified Azure Storage blobs
队列存储 :响应 Azure 存储队列消息Queue storage : Respond to Azure Storage queue messages
事件网格 : 通过订阅和筛选器响应 Azure 事件网格事件Event Grid : Respond to Azure Event Grid events via subscriptions and filters
事件中心 :响应 大量 Azure 事件中心事件Event Hub : Respond to high-volumes of Azure Event Hub events
服务总线队列 :通过 对服务总线队列消息做出响应连接到其他 Azure 服务或本地服务Service Bus Queue : Connect to other Azure or on-premises services by responding Service Bus queue messages
服务总线主题 :通过 对服务总线主题消息做出响应连接到其他 Azure 服务或本地服务Service Bus Topic : Connect other Azure services or on-premises services by responding to Service Bus topic messages
Functions 的费用是多少?How much does Functions cost?
Azure Functions 有三种定价计划。Azure Functions has three kinds of pricing plans. 请选择最适合自己的那种:Choose the one that best fits your needs:
消耗计划 :Azure 提供了所有必要的计算资源。Consumption plan : Azure provides all of the necessary computational resources. 你不必担心资源管理,只需为你的代码运行的时间付费。You don't have to worry about resource management, and only pay for the time that your code runs.
高级计划 :你指定多个预热实例,这些实例始终处于联机状态,并随时可以立即响应。Premium plan : You specify a number of pre-warmed instances that are always online and ready to immediately respond. 函数运行时,Azure 会提供所需的任何其他计算资源。When your function runs, Azure provides any additional computational resources that are needed. 你需要为持续运行的预热实例以及在 Azure 缩放应用时使用的任何其他实例付费。You pay for the pre-warmed instances running continuously and any additional instances you use as Azure scales your app in and out.
应用服务计划 :将函数像 Web 应用一样运行。App Service plan : Run your functions just like your web apps. 如果已对其他应用程序使用应用服务,可以按相同的计划运行你的函数,不用另外付费。If you use App Service for your other applications, your functions can run on the same plan at no additional cost.
有关托管计划的详细信息,请参阅 Azure Functions 托管计划比较。For more information about hosting plans, see Azure Functions hosting plan comparison. 完整的定价详细信息可在 Functions 定价页中找到。Full pricing details are available on the Functions Pricing page.
后续步骤Next Steps
创建第一个 Azure 函数Create your first Azure Function
通过 Visual Studio Code、命令行开始入门,也可以使用 Azure 门户。Get started with Visual Studio Code, the command line, or use the Azure portal.Azure Functions 开发人员参考Azure Functions developer reference
提供有关 Azure Functions 运行时的更多技术信息,并为编码函数及定义触发器和绑定提供参考。Provides more technical information about the Azure Functions runtime and a reference for coding functions and defining triggers and bindings.如何缩放 Azure FunctionsHow to scale Azure Functions
讨论 Azure Functions 提供的服务计划(包括使用托管计划)以及如何选择合适的计划。Discusses service plans available with Azure Functions, including the Consumption hosting plan, and how to choose the right plan.详细了解 Azure 应用服务Learn more about Azure App Service
Azure Functions 利用 Azure 应用服务执行核心功能,例如部署、环境变量和诊断。Azure Functions leverages Azure App Service for core functionality like deployments, environment variables, and diagnostics.