Skip to content

Commit eafd1fb

Browse files
committed
mentioned support for Flex in ADO deploy task
1 parent 1c4918b commit eafd1fb

File tree

1 file changed

+43
-31
lines changed

1 file changed

+43
-31
lines changed

articles/azure-functions/functions-how-to-azure-devops.md

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Continuously update function app code using Azure Pipelines
33
description: Learn how to use Azure Pipelines to set up a pipeline that builds and deploys apps to Azure Functions.
44
author: juliakm
55
ms.topic: conceptual
6-
ms.date: 04/03/2024
6+
ms.date: 09/27/2024
77
ms.author: jukullam
88
ms.custom: devx-track-csharp, devx-track-azurecli, devops-pipelines-deploy
99
ms.devlang: azurecli
@@ -186,7 +186,7 @@ steps:
186186
187187
You'll deploy with the [Azure Function App Deploy](/azure/devops/pipelines/tasks/deploy/azure-function-app) task. This task requires an [Azure service connection](/azure/devops/pipelines/library/service-endpoints) as an input. An Azure service connection stores the credentials to connect from Azure Pipelines to Azure.
188188
189-
To deploy to Azure Functions, add the following snippet at the end of your `azure-pipelines.yml` file. The default `appType` is Windows. You can specify Linux by setting the `appType` to `functionAppLinux`.
189+
To deploy to Azure Functions, add the following snippet at the end of your `azure-pipelines.yml` file. The default `appType` is Windows. You can specify Linux by setting the `appType` to `functionAppLinux`. Deploying to a Flex Consumption app is not supported with @v1 of the AzureFunctionApp task.
190190

191191
```yaml
192192
trigger:
@@ -435,8 +435,35 @@ You'll deploy with the [Azure Function App Deploy v2](/azure/devops/pipelines/ta
435435

436436
The v2 version of the task includes support for newer applications stacks for .NET, Python, and Node. The task includes networking predeployment checks. When there are predeployment issues, deployment stops.
437437

438-
To deploy to Azure Functions, add the following snippet at the end of your `azure-pipelines.yml` file. The default `appType` is Windows. You can specify Linux by setting the `appType` to `functionAppLinux`.
438+
To deploy to Azure Functions, add the following snippet at the end of your `azure-pipelines.yml` file. The default `appType` is Windows. You can specify Linux by setting the `appType` to `functionAppLinux`. Deploying to a Flex Consumption app requires you to set both `appType: functionAppLinux` and `isFlexConsumption: true`.
439439

440+
### [Windows App](#tab/windows)
441+
```yaml
442+
trigger:
443+
- main
444+
445+
variables:
446+
# Azure service connection established during pipeline creation
447+
azureSubscription: <Name of your Azure subscription>
448+
appName: <Name of the function app>
449+
# Agent VM image name
450+
vmImageName: 'windows-latest'
451+
452+
- task: AzureFunctionApp@2 # Add this at the end of your file
453+
inputs:
454+
azureSubscription: <Azure service connection>
455+
appType: functionApp # this specifies a Windows-based function app
456+
appName: $(appName)
457+
package: $(System.ArtifactsDirectory)/**/*.zip
458+
deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required. Deployment method. Default: auto.
459+
#Uncomment the next lines to deploy to a deployment slot
460+
#Note that deployment slots is not supported for Linux Dynamic SKU
461+
#deployToSlotOrASE: true
462+
#resourceGroupName: '<Resource Group Name>'
463+
#slotName: '<Slot name>'
464+
```
465+
466+
### [Linux App](#tab/linux)
440467
```yaml
441468
trigger:
442469
- main
@@ -451,7 +478,8 @@ variables:
451478
- task: AzureFunctionApp@2 # Add this at the end of your file
452479
inputs:
453480
azureSubscription: <Azure service connection>
454-
appType: functionAppLinux # default is functionApp
481+
appType: functionAppLinux # This specifies a Linux-based function app
482+
#isFlexConsumption: true # Uncomment this line if you are deploying to a Flex Consumption app
455483
appName: $(appName)
456484
package: $(System.ArtifactsDirectory)/**/*.zip
457485
deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required. Deployment method. Default: auto.
@@ -464,6 +492,17 @@ variables:
464492

465493
The snippet assumes that the build steps in your YAML file produce the zip archive in the `$(System.ArtifactsDirectory)` folder on your agent.
466494

495+
If you opted to deploy to a [deployment slot](functions-deployment-slots.md), you can add the following step to perform a slot swap. Deployment slots are not yet available for the Flex Consumption SKU.
496+
```yaml
497+
- task: AzureAppServiceManage@0
498+
inputs:
499+
azureSubscription: <Azure service connection>
500+
WebAppName: <name of the Function app>
501+
ResourceGroupName: <name of resource group>
502+
SourceSlot: <slot name>
503+
SwapWithProduction: true
504+
```
505+
467506
## Deploy a container
468507

469508
You can automatically deploy your code to Azure Functions as a custom container after every successful build. To learn more about containers, see [Working with containers and Azure Functions](./functions-how-to-custom-container.md) .
@@ -498,33 +537,6 @@ variables:
498537

499538
The snippet pushes the Docker image to your Azure Container Registry. The **Azure Function App on Container Deploy** task pulls the appropriate Docker image corresponding to the `BuildId` from the repository specified, and then deploys the image.
500539

501-
## Deploy to a slot
502-
503-
You can configure your function app to have multiple slots. Slots allow you to safely deploy your app and test it before making it available to your customers.
504-
505-
The following YAML snippet shows how to deploy to a staging slot, and then swap to a production slot:
506-
507-
```yaml
508-
- task: AzureFunctionApp@2
509-
inputs:
510-
azureSubscription: <Azure service connection>
511-
appType: functionAppLinux
512-
appName: <Name of the Function app>
513-
package: $(System.ArtifactsDirectory)/**/*.zip
514-
deploymentMethod: 'auto'
515-
deployToSlotOrASE: true
516-
resourceGroupName: <Name of the resource group>
517-
slotName: staging
518-
519-
- task: AzureAppServiceManage@0
520-
inputs:
521-
azureSubscription: <Azure service connection>
522-
WebAppName: <name of the Function app>
523-
ResourceGroupName: <name of resource group>
524-
SourceSlot: staging
525-
SwapWithProduction: true
526-
```
527-
528540
## Create a pipeline with Azure CLI
529541

530542
To create a build pipeline in Azure, use the `az functionapp devops-pipeline create` [command](/cli/azure/functionapp/devops-pipeline#az-functionapp-devops-pipeline-create). The build pipeline is created to build and release any code changes that are made in your repo. The command generates a new YAML file that defines the build and release pipeline and then commits it to your repo. The prerequisites for this command depend on the location of your code.

0 commit comments

Comments
 (0)