在应用服务计划中创建 Function AppCreate a Function App in an App Service plan

此 Azure Functions 示例脚本将创建一个函数应用,作为函数的容器。This Azure Functions sample script creates a function app, which is a container for your functions. 创建的函数应用使用专用应用服务计划,这意味着服务器资源将始终启用。The function app that is created uses a dedicated App Service plan, which means your server resources are always on.

如果没有 Azure 订阅,可在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

如果选择在本地安装并使用 CLI,本文要求使用 Azure CLI 2.0 或更高版本。If you choose to install and use the CLI locally, this article requires the Azure CLI version 2.0 or later. 运行 az --version 即可查找版本。Run az --version to find the version. 如需进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install the Azure CLI.

示例脚本Sample script

此脚本使用专用应用服务计划创建 Azure Function App。This script creates an Azure Function app using a dedicated App Service plan.

#!/bin/bash

# Create a resource resourceGroupName
az group create `
  --name myResourceGroup `
  --location chinanorth

# Create an azure storage account
az storage account create `
  --name myappsvcpstore `
  --location chinanorth `
  --resource-group myResourceGroup `
  --sku Standard_LRS

# Create an App Service plan
az appservice plan create `
  --name myappserviceplan `
  --resource-group myResourceGroup `
  --location chinanorth

# Create a Function App
az functionapp create `
  --name myappsvcpfunc `
  --storage-account myappsvcpstore `
  --plan myappserviceplan `
  --resource-group myResourceGroup

清理部署Clean up deployment

运行示例脚本后,可以使用以下命令删除资源组以及与其关联的所有资源。After the sample script has been run, the following command can be used to remove the resource group and all resources associated with it.

az group delete --name myResourceGroup

脚本说明Script explanation

表中的每条命令均链接到特定于命令的文档。Each command in the table links to command specific documentation. 此脚本使用以下命令:This script uses the following commands:

命令Command 注释Notes
az group createaz group create 创建用于存储所有资源的资源组。Creates a resource group in which all resources are stored.
az storage account createaz storage account create 创建 Azure 存储帐户。Creates an Azure Storage account.
az appservice plan createaz appservice plan create 创建应用服务计划。Creates an App Service plan.
az functionapp createaz functionapp create 在应用服务计划中创建函数应用。Creates a function app in the App Service plan.

后续步骤Next steps

有关 Azure CLI 的详细信息,请参阅 Azure CLI 文档For more information on the Azure CLI, see Azure CLI documentation.

可以在 Azure Functions 文档中找到其他 Azure Functions CLI 脚本示例。Additional Azure Functions CLI script samples can be found in the Azure Functions documentation.