Skip to content

Latest commit

 

History

History
92 lines (56 loc) · 7.05 KB

create-resources-azure-powershell.md

File metadata and controls

92 lines (56 loc) · 7.05 KB
title description ms.topic ms.custom ms.date
Create function app resources in Azure using PowerShell
Azure PowerShell scripts that show you how to create the Azure resources required to host your functions code in Azure.
sample
devx-track-azurepowershell, devx-track-python
05/02/2023

Create function app resources in Azure using PowerShell

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.

After the resources are created, you can deploy your project files to the new function app. To learn more, see Deployment methods.

Every function app requires your PowerShell scripts to create the following resources:

Resource cmdlet Description
Resource group New-AzResourceGroup Creates a resource group in which you'll create your function app.
Storage account New-AzStorageAccount Creates a storage account 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.
App Service plan 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, since Consumption plans are created when you run New-AzFunctionApp. For more information, see Azure Functions hosting options.
Function app 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.

This article contains the following examples:

[!INCLUDE azure-powershell-requirements]

[!INCLUDE quickstarts-free-trial-note]

Create a serverless function app for C#

The following script creates a serverless C# function app in the default Consumption plan:

:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-consumption/create-function-app-consumption.ps1" id="FullScript":::

Create a serverless function app for Python

The following script creates a serverless Python function app in a Consumption plan:

:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-consumption-python/create-function-app-consumption-python.ps1" id="FullScript":::

Create a scalable function app in a Premium plan

The following script creates a C# function app in an Elastic Premium plan that supports dynamic scale:

:::code language="azurepowershell-interactive" source="~/functions-docs-powershell/azure-functions/create-function-app-premium-plan/create-function-app-premium-plan.ps1" id="FullScript":::

Create a function app in a Dedicated plan

The following script creates a function app hosted in a Dedicated plan, which isn't scaled dynamically by Functions:

:::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":::

Create a function app with a named Storage connection

The following script creates a function app with a named Storage connection in application settings:

:::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":::

Create a function app with an Azure Cosmos DB connection

The following script creates a function app and a connected Azure Cosmos DB account:

:::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":::

Create a function app with continuous deployment

The following script creates a function app that has continuous deployment configured to publish from a public GitHub repository:

:::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":::

Create a serverless Python function app and mount file share

The following script creates a Python function app on Linux and creates and mounts an external Azure Files share:

:::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":::

Mounted file shares are only supported on Linux. For more information, see Mount file shares.

[!INCLUDE powershell-samples-clean-up]

Next steps

For more information on Azure PowerShell, see Azure PowerShell documentation.