Manage your function app

In Azure Functions, a function app provides the execution context for your individual functions. Function app behaviors apply to all functions hosted by a given function app. All functions in a function app must be of the same language.

Individual functions in a function app are deployed together and are scaled together. All functions in the same function app share resources, per instance, as the function app scales.

Connection strings, environment variables, and other application settings are defined separately for each function app. Any data that must be shared between function apps should be stored externally in a persisted store.

Get started in the Azure portal

  1. To begin, go to the Azure portal and sign in to your Azure account. In the search bar at the top of the portal, enter the name of your function app and select it from the list.

  2. Under Settings in the left pane, select Configuration.

    Function app overview in the Azure portal

You can navigate to everything you need to manage your function app from the overview page, in particular the Application settings and Platform features.

Work with application settings

You can create any number of application settings required by your function code. There are also predefined application settings used by Functions. To learn more, see the App settings reference for Azure Functions.

These settings are stored encrypted. To learn more, see Application settings security.

Application settings can be managed from the Azure portal and by using the Azure CLI and Azure PowerShell. You can also manage application settings from Visual Studio Code and from Visual Studio.

To find the application settings, see Get started in the Azure portal.

The Application settings tab maintains settings that are used by your function app. You must select Show values to see the values in the portal. To add a setting in the portal, select New application setting and add the new key-value pair.

Function app settings in the Azure portal.

Use application settings

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:

When you develop a function app locally, you must maintain local copies of these values in the local.settings.json project file. To learn more, see Local settings file.

Hosting plan type

When you create a function app, you also create a hosting plan in which the app runs. A plan can have one or more function apps. The functionality, scaling, and pricing of your functions depend on the type of plan. To learn more, see Azure Functions hosting options.

You can determine the type of plan being used by your function app from the Azure portal, or by using the Azure CLI or Azure PowerShell APIs.

The following values indicate the plan type:

Plan type Portal Azure CLI/PowerShell
Consumption Consumption Dynamic
Premium ElasticPremium ElasticPremium
Dedicated (App Service) Various Various

To determine the type of plan used by your function app, see App Service plan in the Overview tab for the function app in the Azure portal. To see the pricing tier, select the name of the App Service Plan, and then select Properties from the left pane.

View scaling plan in the portal

Plan migration

You can use Azure CLI commands to migrate a function app between a Consumption plan and a Premium plan on Windows. The specific commands depend on the direction of the migration. Direct migration to a Dedicated (App Service) plan isn't currently supported.

This migration isn't supported on Linux.

Consumption to Premium

Use the following procedure to migrate from a Consumption plan to a Premium plan on Windows:

  1. Run the following command to create a new App Service plan (Elastic Premium) in the same region and resource group as your existing function app.

    az functionapp plan create --name <NEW_PREMIUM_PLAN_NAME> --resource-group <MY_RESOURCE_GROUP> --location <REGION> --sku EP1
    
  2. Run the following command to migrate the existing function app to the new Premium plan

    az functionapp update --name <MY_APP_NAME> --resource-group <MY_RESOURCE_GROUP> --plan <NEW_PREMIUM_PLAN>
    
  3. If you no longer need your previous Consumption function app plan, delete your original function app plan after confirming you have successfully migrated to the new one. Run the following command to get a list of all Consumption plans in your resource group.

    az functionapp plan list --resource-group <MY_RESOURCE_GROUP> --query "[?sku.family=='Y'].{PlanName:name,Sites:numberOfSites}" -o table
    

    You can safely delete the plan with zero sites, which is the one you migrated from.

  4. Run the following command to delete the Consumption plan you migrated from.

    az functionapp plan delete --name <CONSUMPTION_PLAN_NAME> --resource-group <MY_RESOURCE_GROUP>
    

Premium to Consumption

Use the following procedure to migrate from a Premium plan to a Consumption plan on Windows:

  1. Run the following command to create a new function app (Consumption) in the same region and resource group as your existing function app. This command also creates a new Consumption plan in which the function app runs.

    az functionapp create --resource-group <MY_RESOURCE_GROUP> --name <NEW_CONSUMPTION_APP_NAME> --consumption-plan-location <REGION> --runtime dotnet --functions-version 3 --storage-account <STORAGE_NAME>
    
  2. Run the following command to migrate the existing function app to the new Consumption plan.

    az functionapp update --name <MY_APP_NAME> --resource-group <MY_RESOURCE_GROUP> --plan <NEW_CONSUMPTION_PLAN>
    
  3. Delete the function app you created in step 1, since you only need the plan that was created to run the existing function app.

    az functionapp delete --name <NEW_CONSUMPTION_APP_NAME> --resource-group <MY_RESOURCE_GROUP>
    
  4. If you no longer need your previous Premium function app plan, delete your original function app plan after confirming you have successfully migrated to the new one. Please note that if the plan is not deleted, you will still be charged for the Premium plan. Run the following command to get a list of all Premium plans in your resource group.

    az functionapp plan list --resource-group <MY_RESOURCE_GROUP> --query "[?sku.family=='EP'].{PlanName:name,Sites:numberOfSites}" -o table
    
  5. Run the following command to delete the Premium plan you migrated from.

    az functionapp plan delete --name <PREMIUM_PLAN> --resource-group <MY_RESOURCE_GROUP>
    

Get your function access keys

HTTP triggered functions can generally be called by using a URL in the format: https://<APP_NAME>.azurewebsites.net/api/<FUNCTION_NAME>. When the authorization to your function is set a value other than anonymous, you must also provide an access key in your request. The access key can either be provided in the URL using the ?code= query string or in the request header. To learn more, see Function access keys. There are several ways to get your access keys.

  1. Sign in to the Azure portal, then search for and select Function App.

  2. Select the function you want to verify.

  3. In the left navigation under Functions, select App keys.

    This returns the host keys, which can be used to access any function in the app. It also returns the system key, which gives anyone administrator-level access to the all function app APIs.

You can also practice least privilege by using the key just for the specific function key by selecting Function keys under Developer in your HTTP triggered function.

Platform features

Function apps run in, and are maintained by, the Azure App Service platform. As such, your function apps have access to most of the features of Azure's core web hosting platform. The left pane is where you access the many features of the App Service platform that you can use in your function apps.

Note

Not all App Service features are available when a function app runs on the Consumption hosting plan.

The rest of this article focuses on the following App Service features in the Azure portal that are useful for Functions:

For more information about how to work with App Service settings, see Configure Azure App Service Settings.

App Service editor

The App Service editor

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. This enables you to integrate with the Git repository, run and debug code, and modify function app settings. This editor provides an enhanced development environment for your functions compared with the built-in function editor.

We recommend that you consider developing your functions on your local computer. When you develop locally and publish to Azure, your project files are read-only in the portal. To learn more, see Code and test Azure Functions locally.

Console

Function app console

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.

When developing locally, we recommend using the Azure Functions Core Tools and the Azure CLI.

Advanced tools (Kudu)

Configure Kudu

The advanced tools for App Service (also known as Kudu) provide access to advanced administrative features of your function app. From Kudu, you manage system information, app settings, environment variables, site extensions, HTTP headers, and server variables. You can also launch Kudu by browsing to the SCM endpoint for your function app, like https://<myfunctionapp>.scm.azurewebsites.net/

Deployment Center

When you use a source control solution to develop and maintain your functions code, Deployment Center lets you build and deploy from source control. Your project is built and deployed to Azure when you make updates. For more information, see Deployment technologies in Azure Functions.

Cross-origin resource sharing

To prevent malicious code execution on the client, modern browsers block requests from web applications to resources running in a separate domain. Cross-origin resource sharing (CORS) lets an Access-Control-Allow-Origin header declare which origins are allowed to call endpoints on your function app.

Portal

When you configure the Allowed origins list for your function app, the Access-Control-Allow-Origin header is automatically added to all responses from HTTP endpoints in your function app.

Configure function app's CORS list

When the wildcard (*) is used, all other domains are ignored.

Use the az functionapp cors add command to add a domain to the allowed origins list. The following example adds the contoso.com domain:

az functionapp cors add --name <FUNCTION_APP_NAME> \
--resource-group <RESOURCE_GROUP_NAME> \
--allowed-origins https://contoso.com

Use the az functionapp cors show command to list the current allowed origins.

Authentication

Configure authentication for a function app

When functions use an HTTP trigger, you can require calls to first be authenticated. App Service supports Azure Active Directory authentication and sign-in with social providers, such as Facebook, Microsoft, and Twitter. For details on configuring specific authentication providers, see Azure App Service authentication overview.

Next steps