|
| 1 | +--- |
| 2 | +title: Create function app resources in Azure using PowerShell |
| 3 | +description: Azure PowerShell scripts that show you how to create the Azure resources required to host your functions code in Azure. |
| 4 | +ms.topic: sample |
| 5 | +ms.date: 07/18/2022 |
| 6 | +--- |
| 7 | +# Create function app resources in Azure using PowerShell |
| 8 | + |
| 9 | +The Azure PowerShell example scripts in this article create function apps and other resources required to host your functions in Azure. A function app provides an execution context in which your functions are executed. All functions running in a function app share the same resources and connections, and they're all scaled together. |
| 10 | + |
| 11 | +After the resources are created, you can deploy your project files to the new function app. To learn more, see [Deployment methods](functions-deployment-technologies.md#deployment-methods). |
| 12 | + |
| 13 | +Every function app requires your PowerShell scripts to create the following resources: |
| 14 | + |
| 15 | +| Resource | cmdlet | Description | |
| 16 | +| --- | --- | --- | |
| 17 | +| Resource group | [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) | Creates a [resource group](../azure-resource-manager/management/overview.md) in which you'll create your function app. | |
| 18 | +| Storage account | [New-AzStorageAccount](/powershell/module/az.storage/new-azstorageaccount) | Creates a [storage account](../storage/common/storage-account-create.md) used by your function app. 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](storage-considerations.md#storage-account-requirements). | |
| 19 | +| App Service plan | [New-AzFunctionAppPlan](/powershell/module/az.functions/new-azfunctionappplan) | Explicitly creates a hosting plan, which defines how resources are allocated to your function app. Used only when hosting in a Premium or Dedicated plan. You won't use this cmdlet when hosting in a serverless [Consumption plan](consumption-plan.md), since Consumption plans are created when you run `New-AzFunctionApp`. For more information, see [Azure Functions hosting options](functions-scale.md). | |
| 20 | +| Function app | [New-AzFunctionApp](/powershell/module/az.functions/new-azfunctionapp) | Creates the function app using the required resources. The `-Name` parameter must be a globally unique name across all of Azure App Service. Valid characters in `-Name` are `a-z` (case insensitive), `0-9`, and `-`. Most examples create a function app that supports C# functions. You can change the language by using the `-Runtime` parameter, with supported values of `DotNet`, `Java`, `Node`, `PowerShell`, and `Python`. Use the `-RuntimeVersion` to choose a [specific language version](supported-languages.md#languages-by-runtime-version). | |
| 21 | + |
| 22 | +This article contains the following examples: |
| 23 | + |
| 24 | +* [Create a serverless function app for C#](#create-a-serverless-function-app-for-c) |
| 25 | +* [Create a serverless function app for Python](#create-a-serverless-function-app-for-python) |
| 26 | +* [Create a scalable function app in a Premium plan](#create-a-scalable-function-app-in-a-premium-plan) |
| 27 | +* [Create a function app in a Dedicated plan](#create-a-function-app-in-a-dedicated-plan) |
| 28 | +* [Create a function app with a named Storage connection](#create-a-function-app-with-a-named-storage-connection) |
| 29 | +* [Create a function app with an Azure Cosmos DB connection](#create-a-function-app-with-an-azure-cosmos-db-connection) |
| 30 | +* [Create a function app with an Azure Cosmos DB connection](#create-a-function-app-with-an-azure-cosmos-db-connection) |
| 31 | +* [Create a function app with continuous deployment](#create-a-function-app-with-continuous-deployment) |
| 32 | +* [Create a serverless Python function app and mount file share](#create-a-serverless-python-function-app-and-mount-file-share) |
| 33 | + |
| 34 | +[!INCLUDE [azure-powershell-requirements](../../includes/azure-powershell-requirements.md)] |
| 35 | + |
| 36 | +[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)] |
| 37 | + |
| 38 | +## Create a serverless function app for C# |
| 39 | + |
| 40 | +The following script creates a serverless C# function app in the default Consumption plan: |
| 41 | + |
| 42 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-consumption/create-function-app-consumption.ps1" id="FullScript"::: |
| 43 | + |
| 44 | +## Create a serverless function app for Python |
| 45 | + |
| 46 | +The following script creates a serverless Python function app in a Consumption plan: |
| 47 | + |
| 48 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-consumption-python/create-function-app-consumption-python.ps1" id="FullScript"::: |
| 49 | + |
| 50 | +## Create a scalable function app in a Premium plan |
| 51 | + |
| 52 | +The following script creates a C# function app in an Elastic Premium plan that supports [dynamic scale](event-driven-scaling.md): |
| 53 | + |
| 54 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-premium-plan/create-function-app-premium-plan.ps1" id="FullScript"::: |
| 55 | + |
| 56 | +## Create a function app in a Dedicated plan |
| 57 | + |
| 58 | +The following script creates a function app hosted in a Dedicated plan, which isn't scaled dynamically by Functions: |
| 59 | + |
| 60 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-app-service-plan/create-function-app-app-service-plan.ps1" id="FullScript"::: |
| 61 | + |
| 62 | +## Create a function app with a named Storage connection |
| 63 | + |
| 64 | +The following script creates a function app with a named Storage connection in application settings: |
| 65 | + |
| 66 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-connect-to-storage/create-function-app-connect-to-storage-account.ps1" id="FullScript"::: |
| 67 | + |
| 68 | +## Create a function app with an Azure Cosmos DB connection |
| 69 | + |
| 70 | +The following script creates a function app and a connected Azure Cosmos DB account: |
| 71 | + |
| 72 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-connect-to-cosmos-db/create-function-app-connect-to-cosmos-db.ps1" id="FullScript"::: |
| 73 | + |
| 74 | +## Create a function app with continuous deployment |
| 75 | + |
| 76 | +The following script creates a function app that has continuous deployment configured to publish from a public GitHub repository: |
| 77 | + |
| 78 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/deploy-function-app-with-function-github-continuous/deploy-function-app-with-function-github-continuous.ps1" id="FullScript"::: |
| 79 | + |
| 80 | +## Create a serverless Python function app and mount file share |
| 81 | + |
| 82 | +The following script creates a Python function app on Linux and creates and mounts an external Azure Files share: |
| 83 | + |
| 84 | +:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/functions-cli-mount-files-storage-linux/functions-cli-mount-files-storage-linux.ps1" id="FullScript"::: |
| 85 | + |
| 86 | +Mounted file shares are only supported on Linux. For more information, see [Mount file shares](storage-considerations.md#mount-file-shares). |
| 87 | + |
| 88 | +[!INCLUDE [powershell-samples-clean-up](../../includes/powershell-samples-clean-up.md)] |
| 89 | + |
| 90 | +## Next steps |
| 91 | + |
| 92 | +For more information on Azure PowerShell, see [Azure PowerShell documentation](/powershell/azure). |
0 commit comments