您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

如何在 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 的概述

可以从概述页导航到管理函数应用所需的所有内容,特别是 应用程序设置平台功能You can navigate to everything you need to manage your function app from the overview page, in particular the Application settings and Platform features.

应用程序设置Application settings

“应用程序设置” 选项卡维护函数应用使用的设置。The Application Settings tab maintains settings that are used by your function app.

Azure 门户中的函数应用设置。

这些设置是加密存储的,必须选择“显示值” 才能查看门户中的值。These settings are stored encrypted, and you must select Show values to see the values in the portal.

若要添加设置,请选择“新建应用程序设置” 并添加新的键值对。To add a setting, select New application setting and add the new key-value pair.

还可以在代码中将函数应用设置值读取为环境变量。The function app settings values can also be read in your code as environment variables. 有关详细信息,请参阅以下特定于语言的参考主题的“环境变量”部分:For more information, see the Environment variables section of these language-specific reference topics:

在本地开发函数应用时,这些值将保留在 local.setings.json 项目文件中。When you develop a function app locally, these values are maintained in the local.settings.json project file.

平台功能Platform features

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.

应用服务编辑器

控制台Console

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.azurewebsites.net/),启动 Kudu You can also launch Kudu by browsing to the SCM endpoint for your function app, like https://<myfunctionapp>.scm.azurewebsites.net/

配置 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、Azure DevOps、Dropbox、Bitbucket 等常用的持续集成解决方案部署函数应用。In addition to traditional FTP upload, Functions lets you deploy your function app using popular continuous integration solutions, like GitHub, Azure DevOps, Dropbox, Bitbucket, and others. 有关详细信息,请参阅 Azure Functions 的连续部署For more information, see Continuous deployment for Azure Functions. 若要使用 FTP 或本地 Git 进行手动上传,还需配置部署凭据To upload manually using FTP or local Git, you also must configure your deployment credentials.

CORSCORS

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

身份验证Authentication

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