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

Note

Because of limitations on editing function code in the Azure portal, you should develop your functions locally and publish your code project to a function app in Azure. For more information, see Development limitations in the Azure portal

  1. To begin, sign in to the Azure portal using 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.

FTPS deployment settings

Azure Functions supports deploying project code to your function app by using FTPS. Because this deployment method requires you to sync triggers, this method isn't recommended. To securely transfer project files, always use FTPS and not FTP.

You can get the credentials required for FTPS deployment using one of these methods:

You can get the FTPS publishing credentials in the Azure portal by downloading the publishing profile for your function app.

Important

The publishing profile contains important security credentials. You should always secure the downloaded file on your local computer.

To download the publishing profile of your function app:

  1. Select the function app's Overview page, and then select Get publish profile.

    Download publish profile

  2. Save and copy the contents of the file.

  1. In the file, locate the publishProfile element with the attribute publishMethod="FTP". In this element, the publishUrl, userName, and userPWD attributes contain the target URL and credentials for FTPS publishing.

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 either the Azure portal or Azure CLI commands to migrate a function app between a Consumption plan and a Premium plan on Windows. When migrating between plans, keep in mind the following considerations:

  • Direct migration to a Dedicated (App Service) plan isn't currently supported.
  • Migration isn't supported on Linux.
  • The source plan and the target plan must be in the same resource group and geographical region. For more information, see Move an app to another App Service plan.
  • The specific CLI commands depend on the direction of the migration.
  • Downtime in your function executions occurs as the function app is migrated between plans.
  • State and other app-specific content is maintained, since the same Azure Files share is used by the app both before and after migration.

Migration in the portal

In the Azure portal, navigate to your Consumption or Premium plan app and choose Change App Service plan under App Service plan. Select the other Plan type, create a new App Service plan of the new type, and select OK. For more information, see Move an app to another App Service plan.

Consumption to Premium

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

  1. Run the az functionapp plan create command as follows 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 az functionapp update command as follows 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 az functionapp plan list command as follows 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 az functionapp plan delete command as follows 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 az functionapp plan create command as follows 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 az functionapp update command as follows 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> --force
    
  3. Run the az functionapp delete command as follows to 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. Until the Premium plan is deleted, you continue to be charged for it. Run the az functionapp plan list command as follows 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 az functionapp plan delete command as follows 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.

Development limitations in the Azure portal

You must consider these limitations when developing your functions in the Azure portal:

  • In-portal editing is only supported for JavaScript, PowerShell, Python, and C# Script functions.
  • Python in-portal editing is only supported when running in the Consumption plan.
  • In-portal editing is currently only supported for functions that were created or last modified in the portal.
  • When you deploy code to a function app from outside the portal, you can no longer edit any of the code for that function app in the portal. In this case, just continue using local development.
  • For compiled C# functions, Java functions, and some Python functions, you can create the function app and related resources in the portal. However, you must create the functions code project locally and then publish it to Azure.

When possible, you should develop your functions locally and publish your code project to a function app in Azure. For more information, see Code and test Azure Functions locally.

Manually install extensions

C# class library functions can include the NuGet packages for binding extensions directly in the class library project. For other non-.NET languages and C# script, you should use extension bundles. If you must manually install extensions, you can do so by using Azure Functions Core Tools locally. If you can't use extension bundles and are only able to work in the portal, you need to use Advanced Tools (Kudu) to manually create the extensions.csproj file directly in the site. Make sure to first remove the extensionBundle element from the host.json file.

This same process works for any other file you need to add to your app.

Important

When possible, you shouldn't edit files directly in your function app in Azure. We recommend downloading your app files locally, using Core Tools to install extensions and other packages, validating your changes, and then republishing your app using Core Tools or one of the other supported deployment methods.

The Functions editor built into the Azure portal lets you update your function code and configuration files directly in the portal.

  1. Select your function app, then under Functions select Functions.
  2. Choose your function and select Code + test under Developer.
  3. Choose your file to edit and select Save when you're done.

Files in the root of the app, such as function.proj or extensions.csproj need to be created and edited by using the Advanced Tools (Kudu).

  1. Select your function app, then under Development tools select Advanced tools > Go.

  2. If prompted, sign-in to the SCM site with your Azure credentials.

  3. From the Debug console menu, choose CMD.

  4. Navigate to .\site\wwwroot, select the plus (+) button at the top, and select New file.

  5. Name the file, such as extensions.csproj and press Enter.

  6. Select the edit button next to the new file, add or update code in the file, and select Save.

  7. For a project file like extensions.csproj, run the following command to rebuild the extensions project:

    dotnet build extensions.csproj
    

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. When working in the Azure portal, the left pane is where you access the many features of the App Service platform that you can use in your function apps.

The following matrix indicates portal feature support by hosting plan and operating system:

Feature Consumption plan Premium plan Dedicated plan
Advanced tools (Kudu) Windows: ✔
Linux: X
App Service editor Windows: ✔
Linux: X
Windows: ✔
Linux: X
Windows: ✔
Linux: X
Backups X X
Console Windows: command-line
Linux: X
Windows: command-line
Linux: SSH
Windows: command-line
Linux: SSH

The rest of this article focuses on the following features in the portal that are useful for your function apps:

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

The wildcard (*) is ignored if there's another domain entry.

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 Microsoft Entra 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