Automating Fabric Deployment with DevOps Scheduled Pipelines

In this article, we’ll are being very serious and will discuss how to set up a DevOps schedule to call a PowerShell script for deploying an Azure Service Fabric application.

Previously, we created a pipeline to promote changes across Development, Test, and Production workspaces. However, a robust Application Lifecycle Management (ALM) process requires more automation. This time, we’ll use scheduled PowerShell scripts in Azure DevOps to streamline deployment tasks.

s


DevOps YAML Pipeline for Scheduled Deployment

trigger: none

schedules:

  – cron: “0 2 * * *”  # Schedule to run at 2 AM daily

    displayName: Nightly Deployment

    branches:

      include:

        – main

    always: true

pool:

  vmImage: ‘windows-latest’

variables:

  ClusterEndpoint: “<your-cluster-endpoint>”  # Endpoint of the Service Fabric cluster

  AppPackagePath: “<path-to-your-application-package>”  # Path to the application package

  ApplicationName: “<application-instance-name>”  # Name of the application instance

  ApplicationTypeName: “<application-type-name>”  # Application type name

  ApplicationTypeVersion: “<application-type-version>”  # Version of the application type

  DeploymentPipelineName: “FabricDeployment”  # Name of the deployment pipeline

  SourceStageName: “Development”  # Source environment for deployment

  TargetStageName: “Test”  # Target environment for deployment

  DeploymentNote: “Daily Deployment”  # Description or note for the deployment

steps:

  – task: PowerShell@2

    displayName: “Deploy Azure Service Fabric Application”

    inputs:

      filePath: “$(System.DefaultWorkingDirectory)/scripts/Deploy-ServiceFabricApp.ps1”

      arguments: >

        -ClusterEndpoint $(ClusterEndpoint)

        -AppPackagePath $(AppPackagePath)

        -ApplicationName $(ApplicationName)

        -ApplicationTypeName $(ApplicationTypeName)

        -ApplicationTypeVersion $(ApplicationTypeVersion)

      failOnStderr: true

Above yaml will call the powershell script in following link.

https://github.com/microsoft/fabric-samples/blob/main/features-samples/fabric-apis/DeploymentPipelines-DeployAll.ps1

Leave a Reply