Automate Azure Functions Flex Consumption Deployments with Azure DevOps and Azure CLI - CloudFronts

Automate Azure Functions Flex Consumption Deployments with Azure DevOps and Azure CLI

Building low-latency, VNET-secure APIs with Azure Functions Flex Consumption is only the beginning.
The next step toward modernization is setting up a DevOps release pipeline that automatically deploys your Function Apps-even across multiple regions – using Azure CLI.

In this blog, we’ll explore how to implement a CI/CD pipeline using Azure DevOps and Azure CLI to deploy Azure Functions (Flex Consumption), handle cross-platform deployment scenarios, and ensure global availability.

Step-by-Step Guide: Azure DevOps Pipeline for Azure Functions Flex Consumption

Step 1: Prerequisites

You’ll need:

  • Azure DevOps project with repository access
  • Azure subscription with Flex Consumption enabled
  • Service Principal with Contributor access
  • Function build artifact (.zip file)

Step 2: Provision Function Infrastructure Using Azure CLI

az group create --name MyRG --location eastus

az storage account create --name mystorage123 --location eastus --resource-group MyRG --sku Standard_LRS

az functionapp plan create --name MyFlexPlan --resource-group MyRG --location eastus --sku FC1 --is-flex-consumption true

az functionapp create \
  --name MyFlexFuncApp \
  --storage-account mystorage123 \
  --plan MyFlexPlan \
  --resource-group MyRG \
  --runtime dotnet-isolated \
  --functions-version 4 \
  --vnet MyVnet

Step 3: Configure Azure DevOps Release Pipeline

  1. In Azure DevOps, go to Pipelines → Releases.
  2. Add a stage called Deploy to Azure Functions.
  3. Add an Azure CLI task with the following script:
echo "Deploying Azure Function..."
az functionapp deployment source config-zip \
  --src $(System.DefaultWorkingDirectory)/drop/myapi.zip \
  --name MyFlexFuncApp \
  --resource-group MyRG
  1. Connect the release to your build artifact (.zip package).

Important Note: Windows vs Linux in Flex Consumption

While creating your pipeline, you might notice a critical difference:

The Azure Functions Flex Consumption plan only supports Linux environments.

If your existing Azure Function was originally created on a Windows-based plan, you cannot use the standard “Azure Function App Deploy” DevOps task, as it assumes Windows compatibility and won’t deploy successfully to Linux-based Flex Consumption.

To overcome this, you must use Azure CLI commands (config-zip deployment) — exactly as shown above — to manually upload and deploy your packaged function code.

This method works regardless of the OS runtime and ensures smooth deployment to Flex Consumption Functions without compatibility issues.

Tip: Before migration, confirm that your Function’s runtime stack supports Linux. Most modern stacks like .NET 6+, Node.js, and Python run natively on Linux in Flex Consumption.

Step 4: Secure Configurations and Secrets

Use Azure Key Vault integration to safely inject configuration values:

az functionapp config appsettings set \
  --name MyFlexFuncApp \
  --resource-group MyRG \
  --settings "DB_CONNECTION=$(DB_CONNECTION)"

Step 5: Enable VNET Integration

If your Function App accesses internal resources, enable VNET integration:

az functionapp vnet-integration add \
  --name MyFlexFuncApp \
  --resource-group MyRG \
  --vnet MyVnet \
  --subnet MySubnet

Step 6: Multi-Region Deployment for High Availability

For global coverage, you can deploy your Function Apps to multiple regions using Azure CLI:

echo "Deploying functions in West India"
echo "Deploying function: function_name1"
az functionapp deployment source config-zip \
  -g $(ResourceGroup1) \
  -n function_name1 \
  --src $(Source)

echo "Deploying functions in Any Region"
echo "Deploying function: function_name2"
az functionapp deployment source config-zip \
  -g $(ResourceGroup1) \
  -n function_name2 \
  --src $(Source)

Dynamic Version (Recommended):

for region in "westindia" "*"
do
  echo "Deploying Azure Function to $region"
  az functionapp deployment source config-zip \
    -g "RG-$region" \
    -n "myfunction-$region" \
    --src $(Source)
done

This ensures consistent global rollouts across regions.

Step 7: Rollback Strategy

If deployment fails in a specific region, your pipeline can automatically roll back:

if [ $? -ne 0 ]; then
  echo "Deployment failed for $region — rolling back..."
  az functionapp deployment source config-zip \
    -g "RG-$region" \
    -n "myfunction-$region" \
    --src $(StableArtifact)
fi

Best Practices

a. Use YAML pipelines for version-controlled CI/CD
b. Use Azure CLI for Flex Consumption deployments (Linux runtime only)
c. Add manual approvals for production
d. Monitor rollouts via Azure Monitor
e. Keep deployment scripts modular and parameterized

To conclude, automating deployments for Azure Functions Flex Consumption using Azure DevOps and Azure CLI gives you:

  • -End-to-end CI/CD automation
  • -Secure, VNET-integrated serverless APIs
  • -Multi-region scalability
  • -OS-compatible deployment flexibility

If your current Azure Function runs on Windows, remember — Flex Consumption supports only Linux-based plans, so CLI-based deployments are the way forward.

Next Step:
Start with one Function App pipeline, validate it in a Linux Flex environment, and expand globally.

For expert support in automating Azure serverless solutions, connect with CloudFronts — your trusted Azure integration partner.

We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange