AzureFunctionAppContainer@1 - Azure Functions for container v1 task

Update a function app with a Docker container.

Update Function Apps with Docker containers.

Syntax

# Azure Functions for container v1
# Update a function app with a Docker container.
- task: AzureFunctionAppContainer@1
  inputs:
    azureSubscription: # string. Required. Azure subscription. 
    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.
    imageName: # string. Required. Image name. 
    #containerCommand: # string. Startup command. 
  # Application and Configuration Settings
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings.
# Azure Function for container v1
# Update Function Apps with Docker containers.
- task: AzureFunctionAppContainer@1
  inputs:
    azureSubscription: # string. Required. Azure subscription. 
    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.
    imageName: # string. Required. Image name. 
    #containerCommand: # string. Startup command. 
  # Application and Configuration Settings
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings.

Inputs

azureSubscription - Azure subscription
string. Required.

Selects the Azure Resource Manager subscription for the deployment.


appName - App name
string. Required.

The name of the Function App for Containers.


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

Set this input to true to deploy to an existing deployment slot or Azure App Service Environment. The task needs a Resource Group name for both targets. For the deployment slot option, the default deploys to the production slot, or you can specify any other existing slot name. 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 name of the Resource Group that contains the Function App for Containers.


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

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


imageName - Image name
string. Required.

A globally unique top-level domain name for your specific registry or namespace.

Note: A fully qualified image name will be of the format: <registry or namespace> <repository> <tag>. For example, myregistry.azurecr.io/nginx:latest.


containerCommand - Startup command
string.

The startup command that executes after deployment. For example, dotnet run dotnet filename.dll.


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.


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 this task to deploy an Azure Function on Linux using a custom image.

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.

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.

Examples

This example deploys Azure Functions on Linux using containers:


variables:
  imageName: contoso.azurecr.io/azurefunctions-containers:$(build.buildId)
  azureSubscription: Contoso
  # To ignore SSL error uncomment the following variable
  # VSTS_ARM_REST_IGNORE_SSL_ERRORS: true

steps:
- task: AzureFunctionAppContainer@1
  displayName: Azure Function App on Container deploy
  inputs:
    azureSubscription: $(azureSubscription)
    appName: functionappcontainers
    imageName: $(imageName)

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