如何在 Azure 门户中管理 Function AppHow to manage a function app in the Azure portal

在 Azure Functions 中,Function App 提供各个函数的执行上下文。In Azure Functions, a function app provides the execution context for your individual functions. Function App 行为适用于由给定 Function App 托管的所有函数。Function app behaviors apply to all functions hosted by a given function app. 本主题介绍如何在 Azure 门户中配置和管理 Function App。This topic describes how to configure and manage your function apps in the Azure portal.

要开始,请转到 Azure 门户,并使用 Azure 帐户登录。To begin, go to the Azure portal and sign in to your Azure account. 在门户顶端的搜索栏中,键入函数应用的名称,并从列表中将其选中。In the search bar at the top of the portal, type the name of your function app and select it from the list. 选择 Function App 后,将看到以下页面:After selecting your function app, you see the following page:

Azure 门户中 Function App 的概述

门户中的收藏函数Favorite Functions in the portal

有时,在 Azure 门户中查找资源可能很难。It can sometimes be hard to find your resources in the Azure portal. 为了更轻松地找到你创建的函数应用,请将函数应用添加到你在门户中的收藏夹。To make it easier to find the function apps you have created, add Function Apps to your favorites in the portal.

  1. 登录到 Azure 门户Log in to the Azure portal.

  2. 单击左下角的箭头以展开所有服务,在“筛选器”字段中键入 Functions,并单击“Function App”旁边的星形。Click the arrow at the bottom left to expand all services, type Functions in the Filter field, and then click the star next to Function Apps.

    在 Azure 门户中创建 Function App

    这会在门户左侧的菜单中添加“函数”图标。This adds the Functions icon to the menu on the left of the portal.

  3. 关闭菜单,向下滚动到底部才能看到“函数”图标。Close the menu, then scroll down to the bottom to see the Functions icon. 单击该图标可查看所有 Function App 的列表。Click this icon to see a list of all your function apps. 单击 Function App 以在此应用中使用函数。Click your function app to work with functions in this app.


Function App 设置边栏选项卡Function app settings tab

Azure 门户中 Function App 的概述。

可在“设置”选项卡中更新 Function App 使用的 Functions 运行时版本。The Settings tab is where you can update the Functions runtime version used by your function app. 也可在其中管理用于限制对 Function App 托管的所有函数的 HTTP 访问的主机密钥。It is also where you manage the host keys used to restrict HTTP access to all functions hosted by the function app.

Functions 支持消耗托管计划和应用服务托管计划。Functions supports both Consumption hosting and App Service hosting plans. 有关详细信息,请参阅为 Azure Functions 选择正确的服务计划For more information, see Choose the correct service plan for Azure Functions. 为获得消耗计划更好的预测性,Functions 允许通过设置每日使用配额(以千兆字节/秒为单位),从而限制平台使用。For better predictability in the Consumption plan, Functions lets you limit platform usage by setting a daily usage quota, in gigabytes-seconds. 一旦达到每日使用配额,Function App 就会停止运行。Once the daily usage quota is reached, the function app is stopped. 可在设置每日支出配额的同一上下文中重新启用因达到支出配额而停止的 Function App。A function app stopped as a result of reaching the spending quota can be re-enabled from the same context as establishing the daily spending quota. 有关计费的详细信息,请参阅 Azure Functions 定价页See the Azure Functions pricing page for details on billing.

平台功能选项卡Platform features tab

Function App 平台功能选项卡。

Function App 运行于 Azure 应用服务平台,并由该平台维护。Function apps run in, and are maintained, by the Azure App Service platform. 在这种情况下,Function App 有权访问 Azure 核心 Web 托管平台的大多数功能。As such, your function apps have access to most of the features of Azure's core web hosting platform. 可在“平台功能”选项卡中访问应用服务平台中许多可用于 Function App 的功能。The Platform features tab is where you access the many features of the App Service platform that you can use in your function apps.


Function App 运行于消耗托管计划中时,并非所有应用服务功能均可用。Not all App Service features are available when a function app runs on the Consumption hosting plan.

本主题的其余部分侧重于 Azure 门户中以下可用于 Functions 的应用服务功能:The rest of this topic focuses on the following App Service features in the Azure portal that are useful for Functions:

若要深入了解如何使用应用服务设置,请参阅配置 Azure 应用服务设置For more information about how to work with App Service settings, see Configure Azure App Service Settings.

应用服务编辑器App Service Editor

Function App 应用服务编辑器。 应用服务编辑器是一种高级的门户内编辑器,可用于修改诸如 JSON 配置文件和代码文件等内容。The App Service editor is an advanced in-portal editor that you can use to modify JSON configuration files and code files alike. 选择此选项会启动单独的浏览器选项卡和基本编辑器。Choosing this option launches a separate browser tab with a basic editor. 借此,可与 Git 存储库集成、运行和调试代码,并可修改 Function App 设置。This enables you to integrate with the Git repository, run and debug code, and modify function app settings. 同默认 Function App 边栏选项卡相比,此编辑器为 Functions 提供了增强的开发环境。This editor provides an enhanced development environment for your functions compared with the default function app blade.


应用程序设置Application settings

Function App 应用程序设置。 可在应用服务“应用程序设置”边栏选项卡中配置和管理框架版本、远程调试、应用设置和连接字符串。The App Service Application settings blade is where you configure and manage framework versions, remote debugging, app settings, and connection strings. 将 Function App 与其他 Azure 和第三方服务集成时,可在此处修改这些设置。When you integrate your function app with other Azure and third-party services, you can modify those settings here. 若要删除设置,请滚动至右侧,并选择该行右端的 X 图标(未显示在下图中)。To delete a setting, scroll to the right and select the X icon at the right end of the line (not shown in the following image).



Azure 门户中的 Function App 控制台 要从命令行与 Function App 交互时,门户内控制台就是非常合适的开发人员工具。The in-portal console is an ideal developer tool when you prefer to interact with your function app from the command line. 常见命令包括创建和导航目录与文件,以及执行批处理文件和脚本。Common commands include directory and file creation and navigation, as well as executing batch files and scripts.

Function App 控制台

高级工具 (Kudu)Advanced tools (Kudu)

Azure 门户中的 Function App Kudu 应用服务的高级工具(也称为 Kudu)提供对 Function App 高级管理功能的访问。The advanced tools for App Service (also known as Kudu) provide access to advanced administrative features of your function app. 从 Kudu 中,可以管理系统信息、应用设置、环境变量、站点扩展、HTTP 头和服务器变量。From Kudu, you manage system information, app settings, environment variables, site extensions, HTTP headers, and server variables. 也可以通过浏览到 Function App 的 SCM 终结点(如 https://<myfunctionapp>.scm.chinacloudsites.cn/),启动 KuduYou can also launch Kudu by browsing to the SCM endpoint for your function app, like https://<myfunctionapp>.scm.chinacloudsites.cn/

配置 Kudu

部署选项Deployment options

Azure 门户中的 Function App 部署选项 Functions 允许在本地计算机上开发函数代码。Functions lets you develop your function code on your local machine. 然后,可将本地 Function App 项目上传到 Azure。You can then upload your local function app project to Azure. 除了传统的 FTP 上传外,Functions 还允许使用 GitHub、Dropbox、Bitbucket 等常用的持续集成解决方案部署函数应用。In addition to traditional FTP upload, Functions lets you deploy your function app using popular continuous integration solutions, like GitHub, Dropbox, Bitbucket, and others.


Azure 门户中的 Function App CORS 为了防止在服务中执行破坏性代码,应用服务将阻止从外部源调用 Function App。To prevent malicious code execution in your services, App Service blocks calls to your function apps from external sources. Functions 支持跨源资源共享 (CORS),以便定义允许源的“允许列表”,函数可接受来自该允许源的远程请求。Functions supports cross-origin resource sharing (CORS) to let you define a "whitelist" of allowed origins from which your functions can accept remote requests.

配置函数应用的 CORS


Azure 门户中的 Function App 身份验证 函数使用 HTTP 触发器时,可以要求首先对调用进行身份验证。When functions use an HTTP trigger, you can require calls to first be authenticated. 应用服务支持 Azure Active Directory 身份验证和使用社交提供程序(如 Microsoft)登录。App Service supports Azure Active Directory authentication and sign in with social providers, such as Microsoft. 有关配置特定身份验证提供程序的详细信息,请参阅 Azure 应用服务身份验证概述For details on configuring specific authentication providers, see Azure App Service authentication overview.

配置 Function App 的身份验证

API 定义API definition

Azure 门户中的 Function App API Swagger 定义 Functions 支持 Swagger,以便使客户更轻松地使用 HTTP 触发的函数。Functions supports Swagger to allow clients to more easily consume your HTTP-triggered functions. 有关使用 Swagger 创建 API 定义的详细信息,请访问在 Azure 应用服务中使用 CORS 托管 RESTful APIFor more information on creating API definitions with Swagger, visit Host a RESTful API with CORS in Azure App Service. 还可以使用函数代理来定义多个函数的单个 API 图面。You can also use Functions Proxies to define a single API surface for multiple functions. 有关详细信息,请参阅使用 Azure Functions 代理For more information, see Working with Azure Functions Proxies.

配置函数应用的 API

后续步骤Next steps