Azure Function App for Container task

Azure DevOps Services

Use this task to deploy an Azure Function on Linux using a custom image.

Task Inputs

ParametersDescription
azureSubscription
Azure subscription
(Required) Name of an Azure Resource Manager service connection.
appName
App name
(Required) Name of the Function App for Containers.
deployToSlotOrASE
Deploy to Slot or App Service Environment
(Optional) Set to true to deploy to an existing deployment slot or Azure App Service Environment. For both the targets, the task needs a Resource Group name. For the deployment slot option, the default is to deploy 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 just specify the Resource Group name.
Default value: false
resourceGroupName
Resource group
(Required if deployToSlotOrASE is true) Name of the Resource Group containing the Function App for Containers.
slotName
Slot
(Required) Enter or select an existing slot other than the production slot.
Default value: production
imageName
Image name
(Required) Image to be used for deployment.
Example: myregistry.azurecr.io/nginx:latest
containerCommand
Startup command
(Optional) Startup command to be executed after deployment.
appSettings
App settings
(Optional) Application settings to be entered using the syntax '-key value'. Values containing spaces should be enclosed in double quotes.
Example: -Port 5000 -RequestTimeout 5000 -WEBSITE_TIME_ZONE "Eastern Standard Time"
configurationStrings
Configuration settings
(Optional) Configuration strings to be entered using the syntax '-key value'. Values containing spaces should be enclosed in double quotes.
Example: -phpVersion 5.6 -linuxFxVersion: node|6.11

Example

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)

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.

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.

Open Source

This task is open source on GitHub. Feedback and contributions are welcome.