AzureFunctionApp@1 - Azure Functions v1 task

Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications.

Deploy an Azure Function for Linux or Windows.

Syntax

# Azure Functions Deploy v1
# Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications.
- task: AzureFunctionApp@1
  inputs:
    azureSubscription: # string. Required. Azure Resource Manager connection. 
    appType: # 'functionApp' | 'functionAppLinux'. Required. App type. 
    appName: # string. Required. Azure Functions App name. 
    #deployToSlotOrASE: false # boolean. Deploy to Slot or App Service Environment. Default: false.
    #resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group. 
    #slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
    package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #runtimeStack: # 'DOTNET|2.2' | 'DOTNET|3.1' | 'DOTNET|6.0' | 'JAVA|8' | 'JAVA|11' | 'NODE|8' | 'NODE|10' | 'NODE|12' | 'NODE|14' | 'NODE|16' | 'PYTHON|3.6' | 'PYTHON|3.7' | 'PYTHON|3.8' | 'PYTHON|3.9'. Optional. Use when appType = functionAppLinux. Runtime stack. 
    #startUpCommand: # string. Optional. Use when appType = functionAppLinux. Startup command. 
  # Application and Configuration Settings
    #customWebConfig: # string. Optional. Use when appType != functionAppLinux && package NotEndsWith .war. Generate web.config parameters for Python, Node.js, Go and Java apps. 
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings. 
  # Additional Deployment Options
    #deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required when appType != functionAppLinux && appType != "" && package NotEndsWith .war && Package NotEndsWith .jar. Deployment method. Default: auto.
# Azure Functions Deploy v1
# Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications.
- task: AzureFunctionApp@1
  inputs:
    azureSubscription: # string. Required. Azure Resource Manager connection. 
    appType: # 'functionApp' | 'functionAppLinux'. Required. App type. 
    appName: # string. Required. Azure Functions App name. 
    #deployToSlotOrASE: false # boolean. Deploy to Slot or App Service Environment. Default: false.
    #resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group. 
    #slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
    package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #runtimeStack: # 'DOTNET|2.2' | 'DOTNET|3.1' | 'JAVA|8' | 'JAVA|11' | 'NODE|8' | 'NODE|10' | 'NODE|12' | 'NODE|14' | 'PYTHON|3.6' | 'PYTHON|3.7' | 'PYTHON|3.8'. Optional. Use when appType = functionAppLinux. Runtime stack. 
    #startUpCommand: # string. Optional. Use when appType = functionAppLinux. Startup command. 
  # Application and Configuration Settings
    #customWebConfig: # string. Optional. Use when appType != functionAppLinux && package NotEndsWith .war. Generate web.config parameters for Python, Node.js, Go and Java apps. 
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings. 
  # Additional Deployment Options
    #deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required when appType != functionAppLinux && appType != "" && package NotEndsWith .war && Package NotEndsWith .jar. Deployment method. Default: auto.
# Azure Functions Deploy v1
# Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications.
- task: AzureFunctionApp@1
  inputs:
    azureSubscription: # string. Required. Azure Resource Manager connection. 
    appType: # 'functionApp' | 'functionAppLinux'. Required. App type. 
    appName: # string. Required. App name. 
    #deployToSlotOrASE: false # boolean. Deploy to Slot or App Service Environment. Default: false.
    #resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group. 
    #slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
    package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #runtimeStack: # 'DOTNET|2.2' | 'DOTNET|3.1' | 'JAVA|8' | 'JAVA|11' | 'NODE|8' | 'NODE|10' | 'NODE|12' | 'NODE|14' | 'PYTHON|3.6' | 'PYTHON|3.7' | 'PYTHON|3.8'. Optional. Use when appType = functionAppLinux. Runtime stack. 
    #startUpCommand: # string. Optional. Use when appType = functionAppLinux. Startup command. 
  # Application and Configuration Settings
    #customWebConfig: # string. Optional. Use when appType != functionAppLinux && package NotEndsWith .war. Generate web.config parameters for Python, Node.js, Go and Java apps. 
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings. 
  # Additional Deployment Options
    #deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required when appType != functionAppLinux && appType != "" && package NotEndsWith .war && Package NotEndsWith .jar. Deployment method. Default: auto.
# Azure Functions Deploy v1
# Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications.
- task: AzureFunctionApp@1
  inputs:
    azureSubscription: # string. Required. Azure Resource Manager connection. 
    appType: # 'functionApp' | 'functionAppLinux'. Required. App type. 
    appName: # string. Required. App name. 
    #deployToSlotOrASE: false # boolean. Deploy to Slot or App Service Environment. Default: false.
    #resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group. 
    #slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
    package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #runtimeStack: # 'DOCKER|microsoft/azure-functions-dotnet-core2.0:2.0' | 'DOCKER|microsoft/azure-functions-node8:2.0'. Optional. Use when appType = functionAppLinux. Runtime stack. 
    #startUpCommand: # string. Optional. Use when appType = functionAppLinux. Startup command. 
  # Application and Configuration Settings
    #customWebConfig: # string. Optional. Use when appType != functionAppLinux && package NotEndsWith .war. Generate web.config parameters for Python, Node.js, Go and Java apps. 
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings. 
  # Additional Deployment Options
    #deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required when appType != functionAppLinux && appType != "" && package NotEndsWith .war && Package NotEndsWith .jar. Deployment method. Default: auto.
# Azure Functions Deploy v1
# Deploy an Azure Function for Linux or Windows.
- task: AzureFunctionApp@1
  inputs:
    azureSubscription: # string. Required. Azure Resource Manager connection. 
    appType: # 'functionApp' | 'functionAppLinux'. Required. App type. 
    appName: # string. Required. App name. 
    #deployToSlotOrASE: false # boolean. Deploy to Slot or App Service Environment. Default: false.
    #resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group. 
    #slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
    package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #runtimeStack: # 'DOCKER|microsoft/azure-functions-dotnet-core2.0:2.0' | 'DOCKER|microsoft/azure-functions-node8:2.0'. Optional. Use when appType = functionAppLinux. Runtime stack. 
    #startUpCommand: # string. Optional. Use when appType = functionAppLinux. Startup command. 
  # Application and Configuration Settings
    #customWebConfig: # string. Optional. Use when appType != functionAppLinux && package NotEndsWith .war. Generate web.config parameters for Python, Node.js, Go and Java apps. 
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings. 
  # Additional Deployment Options
    #deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required when appType != functionAppLinux && appType != "" && package NotEndsWith .war && Package NotEndsWith .jar. Deployment method. Default: auto.

Inputs

azureSubscription - Azure Resource Manager connection
string. Required.

Selects the Azure Resource Manager subscription for the deployment.


appType - App type
string. Required. Allowed values: functionApp (Function App on Windows), functionAppLinux (Function App on Linux).


appName - Azure Functions App name
string. Required.

Enters or selects the name of an existing Azure Functions App. The Function Apps listed will be based on the selected app type.


appName - App name
string. Required.

Enters or selects the name of an existing Azure Functions App. The Function Apps listed will be based on the selected app type.


deployToSlotOrASE - Deploy to Slot or App Service Environment
boolean. Default value: false.

Deploys to an existing deployment slot or Azure App Service Environment. For both targets, the task needs a Resource group name.

If the deployment target is a slot, it will default to the production slot. Any other existing slot name can also be provided.

If the deployment target is an Azure App Service Environment, leave the slot name as production and specify the Resource group name.


resourceGroupName - Resource group
string. Required when deployToSlotOrASE = true.

The Resource group name is required when the deployment target is either a deployment slot or an App Service Environment.

Enters or selects the Azure Resource group that contains the Azure App Service specified above.


slotName - Slot
string. Required when deployToSlotOrASE = true. Default value: production.

Enters or selects an existing slot, excluding the Production slot.


package - Package or folder
string. Required. Default value: $(System.DefaultWorkingDirectory)/**/*.zip.

The file path to the package or folder that contains App Service content generated by MSBuild, a compressed zip file, or a war file. Variables ( Build | Release) and wildcards are supported. For example, $(System.DefaultWorkingDirectory)/**/*.zip or $(System.DefaultWorkingDirectory)/**/*.war.


runtimeStack - Runtime stack
string. Optional. Use when appType = functionAppLinux. Allowed values: DOTNET|2.2 (DOTNET|2.2 (functionapp v2)), DOTNET|3.1 (DOTNET|3.1 (functionapp v3)), DOTNET|6.0 (DOTNET|6.0 (functionapp v4)), JAVA|8 (JAVA|8 (functionapp v2/v3/v4)), JAVA|11 (JAVA|11 (functionapp v3/v4)), NODE|8 (NODE|8 (functionapp v2)), NODE|10 (NODE|10 (functionapp v2/v3)), NODE|12 (NODE|12 (functionapp v3)), NODE|14 (NODE|14 (functionapp v3/v4)), NODE|16 (NODE|16 (functionapp v4)), PYTHON|3.6 (PYTHON|3.6 (functionapp v2/v3)), PYTHON|3.7 (PYTHON|3.7 (functionapp v2/v3/v4)), PYTHON|3.8 (PYTHON|3.8 (functionapp v3/v4)), PYTHON|3.9 (PYTHON|3.9 (functionapp v3/v4)).

Specify the framework and version your function app will run on. You can use any of the supported runtime versions. Old values like DOCKER|microsoft/azure-functions-* are deprecated. New values are listed in the drop-down list in the task assistant. If there is a newer version of a framework available in the supported runtime versions you can specify it even if it is not in the list.


runtimeStack - Runtime stack
string. Optional. Use when appType = functionAppLinux. Allowed values: DOTNET|2.2 (DOTNET|2.2 (functionapp v2)), DOTNET|3.1 (DOTNET|3.1 (functionapp v3)), JAVA|8 (JAVA|8 (functionapp v2/v3)), JAVA|11 (JAVA|11 (functionapp v3)), NODE|8 (NODE|8 (functionapp v2)), NODE|10 (NODE|10 (functionapp v2/v3)), NODE|12 (NODE|12 (functionapp v3)), NODE|14 (NODE|14 (functionapp v3)), PYTHON|3.6 (PYTHON|3.6 (functionapp v2/v3)), PYTHON|3.7 (PYTHON|3.7 (functionapp v2/v3)), PYTHON|3.8 (PYTHON|3.8 (functionapp v3)).

Specify the framework and version your function app will run on. You can use any of the supported runtime versions. Old values like DOCKER|microsoft/azure-functions-* are deprecated. New values are listed in the drop-down list in the task assistant. If there is a newer version of a framework available in the supported runtime versions you can specify it even if it is not in the list.


runtimeStack - Runtime stack
string. Optional. Use when appType = functionAppLinux. Allowed values: DOCKER|microsoft/azure-functions-dotnet-core2.0:2.0 (.NET), DOCKER|microsoft/azure-functions-node8:2.0 (JavaScript).

Specify the framework and version your function app will run on. You can use any of the supported runtime versions. Old values like DOCKER|microsoft/azure-functions-* are deprecated. New values are listed in the drop-down list in the task assistant. If there is a newer version of a framework available in the supported runtime versions you can specify it even if it is not in the list.


startUpCommand - Startup command
string. Optional. Use when appType = functionAppLinux.

Enters the start up command. For example:

dotnet run
dotnet filename.dll


customWebConfig - Generate web.config parameters for Python, Node.js, Go and Java apps
string. Optional. Use when appType != functionAppLinux && package NotEndsWith .war.

A standard Web.config will be generated and deployed to Azure App Service if the application does not have one. The values in web.config vary based on the application framework, and they can be edited. For example, for the node.js application, web.config will have a startup file and iis_node module values. This edit feature is only for the generated web.config.


appSettings - App settings
string.

Enter the application settings using the syntax -key value (for example: -Port 5000 -RequestTimeout 5000 -WEBSITE_TIME_ZONE). Enclose values that contain spaces in double quotes (for example: "Eastern Standard Time").


configurationStrings - Configuration settings
string.

Enter the configuration strings using the syntax -key value (for example: -phpVersion 5.6 -linuxFxVersion: node|6.11). Enclose values that contain spaces in double quotes.


deploymentMethod - Deployment method
string. Required when appType != functionAppLinux && appType != "" && package NotEndsWith .war && Package NotEndsWith .jar. Allowed values: auto (Auto-detect), zipDeploy (Zip Deploy), runFromPackage (Zip Deploy with Run From Package). Default value: auto.

Chooses the deployment method for the app.


deploymentMethod - Deployment method
string. Required when appType != functionAppLinux && appType != "" && package NotEndsWith .war && Package NotEndsWith .jar. Allowed values: auto (Auto-detect), zipDeploy (Zip Deploy), runFromPackage (Run From Package). Default value: auto.

Chooses the deployment method for the app.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

This task defines the following output variables, which you can consume in downstream steps, jobs, and stages.

AppServiceApplicationUrl
The application URL of the selected App Service.

Remarks

Use the Azure Function App task to deploy functions to Azure.

Deployment methods

Several deployment methods are available in this task. The default value is auto.

To change the package-based deployment option in a designer task, expand Additional Deployment Options and enable Select Deployment Method.

Based on the type of Azure App Service and Azure Pipelines agent, the task uses a suitable deployment technology. The deployment technologies used by tasks are as follows:

By default, the task attempts to select the appropriate deployment technology based on the input package, App Service type, and agent OS.

  • If a post-deployment script is provided, use Zip Deploy.
  • If the App Service type is Web App on Linux, use Zip Deploy.
  • If a .war file is provided, use War Deploy.
  • If a .jar file is provided, use Run-From-Zip.
  • For all other tasks, use Run From Package (via Zip Deploy).

On a non-Windows agent (for any App Service type), the task relies on the Kudu REST API to deploy the web app.

Kudu REST API

The Kudu REST API works on both Windows and Linux automation agents when the target is a Web App on Windows, a Web App on Linux (built-in source), or a function app. The task uses Kudu to copy files to the Azure App Service.

Zip Deploy

Zip Deploy creates a .zip deployment package from the chosen package or folder. It then deploys the file contents to the wwwroot folder of the App Service name function app in Azure. This option overwrites all existing content in the wwwroot folder. For more information, see Zip deployment for Azure Functions.

Run From Package

Run From Package creates the same deployment package as Zip Deploy. Instead of deploying files to the wwwroot folder, the Functions runtime mounts the entire package. When you use this option, files in the wwwroot folder become read-only. For more information, see Run your Azure Functions from a package file.

Troubleshooting

Error: Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.

The task uses the service principal in the service connection to authenticate with Azure. If the service principal has expired or doesn't have permissions to the App Service, the task fails with this error. Verify the validity of the service principal used and that it's present in the app registration. For more information, see Use role-based access control to manage access to your Azure subscription resources. This blog post also contains more information about using service principal authentication.

SSL error

If you want to use a certificate in App Service, the certificate must be signed by a trusted certificate authority. If your web app gives you certificate validation errors, you're probably using a self-signed certificate. Set a variable named VSTS_ARM_REST_IGNORE_SSL_ERRORS to the value true in the build or release pipeline to resolve the error.

A release hangs for long time and then fails

This problem could be the result of insufficient capacity in your App Service plan. To resolve this problem, you can scale up the App Service instance to increase available CPU, RAM, and disk space or try with a different App Service plan.

5xx error codes

If you're seeing a 5xx error, check the status of your Azure service.

Azure Function suddenly stopped working

Azure Functions may suddenly stop working if more than one year has passed since the last deployment. If you deploy with "RunFromPackage" in "deploymentMethod", a SAS with an expiration date of 1 year is generated and set as the value of "WEBSITE_RUN_FROM_PACKAGE" in the application configuration. Azure Functions uses this SAS to reference the package file for function execution, so if the SAS has expired, the function will not be executed. To resolve this issue, deploy again to generate a SAS with an expiration date of one year.

Error: No package found with specified pattern

Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

Error: Publish using zip deploy option is not supported for msBuild package type

Web packages created via the MSBuild task (with default arguments) have a nested folder structure that can be deployed correctly only by Web Deploy. The publish-to-zip deployment option can't be used to deploy those packages. To convert the packaging structure, take these steps:

  1. In the Build solution task, change the MSBuild Arguments to /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="$(System.DefaultWorkingDirectory)\\WebAppContent":

    Screenshot that shows the Build solution values.

  2. Add an Archive task and change the values as follows:

    1. Change Root folder or file to archive to $(System.DefaultWorkingDirectory)\\WebAppContent.

    2. Clear the Prepend root folder name to archive paths check box:

      Screenshot that shows the Archive values.

Function app deployment on Windows succeeds but the app doesn't work

This problem could occur if a web.config file isn't present in your app. You can either add a web.config file to your source or automatically generate one by using the Application and Configuration Settings of the task.

  1. Select the task and go to Generate web.config parameters for Python, Node.js, Go and Java apps:

    Screenshot that shows the Generate web.config parameters section.

  2. Select the More button (...) under Generate web.config parameters for Python, Node.js, Go and Java apps to edit the parameters:

    Screenshot that shows the Generate web.config parameters.

  3. Select your application type in the Application framework list.

  4. Select OK. Doing so will populate the web.config parameters required to generate the web.config file.

FAQs

How should I configure my service connection?

This task requires an Azure Resource Manager service connection.

How should I configure web job deployment with Application Insights?

When you're deploying to an App Service, if you have Application Insights configured and you've enabled Remove additional files at destination, you also need to enable Exclude files from the App_Data folder. Enabling this option keeps the Application Insights extension in a safe state. This step is required because the Application Insights continuous WebJob is installed into the App_Data folder.

How should I configure my agent if it's behind a proxy while I'm deploying to App Service?

If your self-hosted agent requires a web proxy, you can inform the agent about the proxy during configuration. Doing so allows your agent to connect to Azure Pipelines or Azure DevOps Server through the proxy. Learn more about running a self-hosted agent behind a web proxy.

I can't deploy to an internal App Service Environment by using an Azure Resource Manager service connection and a Microsoft-hosted agent

By design, a Microsoft-hosted agent won't work with an App Service Environment. Instead, you need to configure a private agent on a virtual machine that's in the same virtual network as the App Service Environment. Also, set a private DNS zone to enable communication between the resources.

Examples

Here's a sample YAML snippet that deploys Azure functions on Windows:


variables:
  azureSubscription: Contoso
  # To ignore SSL error, uncomment the below variable
  # VSTS_ARM_REST_IGNORE_SSL_ERRORS: true

steps:
- task: AzureFunctionApp@1
  displayName: Azure Function App Deploy
  inputs:
    azureSubscription: $(azureSubscription)
    appName: samplefunctionapp
    appType: functionApp
    package: $(System.DefaultWorkingDirectory)/**/*.zip

To deploy a function on Linux, add the appType parameter and set it to appType: functionAppLinux. If you don't specify a value, functionApp is the default.

To explicitly specify the deployment method as Zip Deploy, add the parameter deploymentMethod: zipDeploy. Another supported value for this parameter is runFromPackage. If you don't specify a value, auto is the default.

For a walkthrough that shows how to create a CI/CD pipeline, see Build and deploy Java to Azure Functions.

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.104.1 or greater
Task category Deploy