通过 Azure 门户创建 Function AppCreate a function app from the Azure portal

本主题演示如何使用 Azure Functions 在 Azure 门户中创建函数应用。This topic shows you how to use Azure Functions to create a function app in the Azure portal. Function App 是托管各个函数执行的容器。A function app is the container that hosts the execution of individual functions.

创建函数应用Create a function app

  1. 在 Azure 门户菜单或“主页”页中,选择“创建资源” 。From the Azure portal menu or the Home page, select Create a resource.

  2. “新建” 页面,选择 “计算” > “函数应用”In the New page, select Compute > Function App.

  3. 在“基本信息”页上,使用下表中指定的函数应用设置。On the Basics page, use the function app settings as specified in the following table.

    设置Setting 建议的值Suggested value 说明Description
    订阅Subscription 你的订阅Your subscription 要在其下创建此新函数应用的订阅。The subscription under which this new function app is created.
    资源组Resource Group myResourceGroupmyResourceGroup 要在其中创建 Function App 的新资源组的名称。Name for the new resource group in which to create your function app.
    函数应用名称Function App name 全局唯一名称Globally unique name 用于标识新 Function App 的名称。Name that identifies your new function app. 有效字符为 a-z(不区分大小写)、0-9-Valid characters are a-z (case insensitive), 0-9, and -.
    Publish 代码Code 用于发布代码文件或 Docker 容器的选项。Option to publish code files or a Docker container.
    运行时堆栈Runtime stack 首选语言Preferred language 选择支持你喜欢的函数编程语言的运行时。Choose a runtime that supports your favorite function programming language. 对于 C# 和 F# 函数,选择 .NET CoreChoose .NET Core for C# and F# functions.
    版本Version 版本号Version number 选择已安装的运行时的版本。Choose the version of your installed runtime.
    区域Region 首选区域Preferred region 选择离你近或离函数访问的其他服务近的区域Choose a region near you or near other services your functions access.

    基础知识

  4. 选择“下一步: 托管”。Select Next : Hosting. 在“托管” 页上,输入以下设置。On the Hosting page, enter the following settings.

    设置Setting 建议的值Suggested value 说明Description
    存储帐户Storage account 全局唯一名称Globally unique name 创建函数应用使用的存储帐户。Create a storage account used by your function app. 存储帐户名称必须为 3 到 24 个字符,并且只能包含数字和小写字母。Storage account names must be between 3 and 24 characters in length and can contain numbers and lowercase letters only. 也可使用现有帐户,但该帐户必须符合存储帐户要求You can also use an existing account, which must meet the storage account requirements.
    操作系统Operating system 首选操作系统Preferred operating system 系统会根据你的运行时堆栈选择为你预先选择一个操作系统,但你可以根据需要更改该设置。An operating system is pre-selected for you based on your runtime stack selection, but you can change the setting if necessary.
    计划Plan 消耗(无服务器)Consumption (Serverless) 定义如何将资源分配给 Function App 的托管计划。Hosting plan that defines how resources are allocated to your function app. 在默认的消耗计划中,根据函数需求动态添加资源。In the default Consumption plan, resources are added dynamically as required by your functions. 在此无服务器托管中,只需为函数运行时间付费。In this serverless hosting, you pay only for the time your functions run. 按应用服务计划运行时,必须管理函数应用的缩放When you run in an App Service plan, you must manage the scaling of your function app.

    Hosting

  5. 选择“下一步: 监视”。Select Next : Monitoring. 在“监视” 页上,输入以下设置。On the Monitoring page, enter the following settings.

    设置Setting 建议的值Suggested value 说明Description
    Application InsightsApplication Insights 默认Default 当前不受支持Not supported currently

    监视

  6. 选择“查看 + 创建”,以便查看应用配置选择。Select Review + create to review the app configuration selections.

  7. 在“查看 + 创建”页上查看设置,然后选择“创建”来预配并部署函数应用 。On the Review + create page, review your settings, and then select Create to provision and deploy the function app.

  8. 选择门户右上角的“通知”图标,留意是否显示了“部署成功”消息。 Select the Notifications icon in the upper-right corner of the portal and watch for the Deployment succeeded message.

  9. 选择“转到资源”,查看新的函数应用。Select Go to resource to view your new function app. 还可选择“固定到仪表板”。You can also select Pin to dashboard. 固定可以更轻松地从仪表板返回此函数应用资源。Pinning makes it easier to return to this function app resource from your dashboard.

    部署通知

创建 Function App 后,可以使用一种或多种不同的语言创建各个函数。After the function app is created, you can create individual functions in one or more different languages. 通过使用门户或通过使用 FTP 上传来创建函数。Create functions by using the portal, or by uploading with FTP.

服务计划Service plans

Azure Functions 有两个不同的服务计划:消耗计划和专用(应用服务)计划。Azure Functions has two different service plans: Consumption plan and Dedicated (App Service) plan. 必须在创建函数应用时选择服务计划,并且随后无法更改。You must choose your service plan when your function app is created, and it cannot subsequently be changed. 有关详细信息,请参阅选择 Azure Functions 托管计划For more information, see Choose an Azure Functions hosting plan.

如果计划在专用(应用服务)计划上运行 JavaScript 函数,则应选择具有较少核心的计划。If you are planning to run JavaScript functions on a Dedicated (App Service) plan, you should choose a plan with fewer cores. 有关详细信息,请参阅函数的 JavaScript 参考For more information, see the JavaScript reference for Functions.

存储帐户要求Storage account requirements

创建函数应用时,必须创建或链接到支持 Blob、队列和表存储的常规用途的 Azure 存储帐户。When creating a function app, you must create or link to a general-purpose Azure Storage account that supports Blob, Queue, and Table storage. Azure Functions 内部使用存储以进行管理触发器和记录函数执行等操作。Internally, Functions uses Storage for operations such as managing triggers and logging function executions. 某些存储帐户不支持队列和表,例如仅限 blob 的存储帐户、Azure 高级存储和使用 ZRS 复制的常规用途的存储帐户。Some storage accounts do not support queues and tables, such as blob-only storage accounts, Azure Premium Storage, and general-purpose storage accounts with ZRS replication. 创建 Function App 时,将从“存储帐户”边栏选项卡中筛选出这些帐户。These accounts are filtered out of from the Storage Account blade when creating a function app.

备注

使用消耗托管计划时,函数代码和绑定配置文件存储在主存储帐户的 Azure 文件存储中。When using the Consumption hosting plan, your function code and binding configuration files are stored in Azure File storage in the main storage account. 删除主存储帐户时,此内容将随之删除且无法恢复。When you delete the main storage account, this content is deleted and cannot be recovered.

若要了解有关存储帐户类型的详细信息,请参阅 Azure 存储服务简介To learn more about storage account types, see Introducing the Azure Storage Services.

后续步骤Next steps

虽然 Azure 门户可以轻松创建和试用 Functions,但我们建议本地开发While the Azure portal makes it easy to create and try out Functions, we recommend local development. 在门户中创建函数应用后,仍然需要添加一个函数。After creating a function app in the portal, you still need to add a function.