← All posts
GitLab CI/CD to Azure App Service for a .NET Framework app
A GitLab CI/CD pipeline that builds a .NET Framework web app and WebJob on Windows runners and deploys to staging, DR and production App Services with Web Deploy.
From the archive · a 2022 working note, kept for reference.
Every development team has unique requirements that can make implementing an efficient deployment pipeline difficult on any cloud service. This is the process we use to prevent downtime:

The CI/CD script
variables:
MSBUILD: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\msbuild.exe"
SOLUTION: IProcessorSolution.sln
WEBJOB_PROJECT: ".\\IProcessorPdfParser\\IProcessorPdfParser.csproj"
DEV_PUBLISH_PROFILE: "IProcessorWebsiteStaging - Web Deploy"
DEV_PUBLISH_PROFILE_WEBJOB_PROJECT: "IProcessorWebsiteStaging - Web Deploy.pubxml"
DEV_DR_PUBLISH_PROFILE: "iprocessorwebsitestaging-dr - Web Deploy"
DEV_DR_PUBLISH_PROFILE_WEBJOB_PROJECT: "iprocessorwebsitestaging-dr - Web Deploy.pubxml"
PROD_DR_PUBLISH_PROFILE: "iprocessorwebsite-dr - Web Deploy"
PROD_DR_PUBLISH_PROFILE_WEBJOB_PROJECT: "iprocessorwebsite-dr - Web Deploy.pubxml"
stages:
- build
- deploy
deploy_dev_dr:
stage: deploy
environment:
name: staging
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != "dev" && $CI_COMMIT_BRANCH != "master"
tags:
- shared-windows
- windows
- windows-1809
script:
- 'nuget restore $SOLUTION'
- '& $MSBUILD $SOLUTION /p:Configuration=Release /p:SignManifests=False /p:DeployOnBuild=true /p:PublishProfile=$DEV_DR_PUBLISH_PROFILE'
- '& $MSBUILD $WEBJOB_PROJECT /p:Configuration=Release /p:SignManifests=False /p:DeployOnBuild=true /p:PublishProfile=$DEV_DR_PUBLISH_PROFILE_WEBJOB_PROJECT'
artifacts:
expire_in: 1 week
deploy_dev:
stage: deploy
environment:
name: staging
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "dev"
tags:
- shared-windows
- windows
- windows-1809
script:
- 'nuget restore $SOLUTION'
- '& $MSBUILD $SOLUTION /p:Configuration=Release /p:SignManifests=False /p:DeployOnBuild=true /p:PublishProfile=$DEV_PUBLISH_PROFILE'
- '& $MSBUILD $WEBJOB_PROJECT /p:Configuration=Release /p:SignManifests=False /p:DeployOnBuild=true /p:PublishProfile=$DEV_PUBLISH_PROFILE_WEBJOB_PROJECT'
artifacts:
expire_in: 1 week
deploy_prod:
stage: deploy
environment:
name: production
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "master"
tags:
- shared-windows
- windows
- windows-1809
script:
- 'nuget restore $SOLUTION'
- '& $MSBUILD $SOLUTION /p:Configuration=Release /p:SignManifests=False /p:DeployOnBuild=true /p:PublishProfile=$PROD_DR_PUBLISH_PROFILE'
- '& $MSBUILD $WEBJOB_PROJECT /p:Configuration=Release /p:SignManifests=False /p:DeployOnBuild=true /p:PublishProfile=$PROD_DR_PUBLISH_PROFILE_WEBJOB_PROJECT'
artifacts:
expire_in: 1 weekFirst published on tanldt.blogspot.com on Feb 19, 2022.