Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

eGIS uses Azure Pieplines to deploy infrastructure as code (IaC) and configuration as code (CaC) to the various eGIS environments. There are two main scenarios in which pipelines are used:

  1. when creating a new eGIS environment, a pipeline is used to deploy the various infrastructure and configuration items to the new environment in sequence; and

  2. when feature branch is merged into the master branch in the eGIS Git repository, a pipeline builds the items that are modified and deploys them to the various eGIS environments in sequence.

Create a Development Pipeline

Create a Service Connection

First, we need to create a service connection to the destination resource group in the EGIS development environment on Azure, if it does not already exist.

  1. First, request a service principal from the Cloud Team. The service principal should be scoped to a particular Azure subscription and resource group.

  2. In Azure DevOps, click on Project Settings.

  3. Expand the Pipelines menu, and click Service Connections.

  4. Click New service connection, and click Azure Resource Manager.

  5. In the Add an Azure Resource Manager service connection window, click use the full version of the service connection dialog.

  6. Specify a Connection name, and enter the Service principal client ID and the Service principal key provided by the Cloud Team.

  7. Click Verify connection.

  8. If the connection is verified successfully, click OK.

Create an Azure Pipeline

The following steps describe how to create a development pipeline for a feature.

  1. In Azure DevOps, expand Pipelines on the left hand menu, and click Builds.

  2. Click New, then click New build pipeline.

  3. Click Use the visual designer.

    Note: In the long term, we should use the YAML editor to define build pipelines, so that our pipelines are implemented as infrastructure as code. This will require trial and error with our pipelines and a better undersrtanding of how to script with YAML.

  4. Choose the feature branch from the dropdown list of branches, and click Continue.

  5. Choose the appropriate template from the list. In this example, the feature is an ASP.NET web app that will be deployed to an Azure App Service.

  6. In the Pipeline blade, specify the Name for the pipeline. and the Visual Studio Solution to build. From the Azure subscription dropdown list, choose the service connection for the resource group to which the app will be deployed (see above). Choiose the App service name (the app service must already exist in the Azure subscription).

  7. On the Triggers tab, in the Continuous integration blade, click Add under Path filters, and specify the folder that contains the components that comprise the feature. We want this pipeline to run when changes are made to this feature, but not when changes are made to other features.

  8. Click Save & queue.

  9. On the Save build pipeline and queue dialog, enter a Save comment and Commit comment, and click Save & queue.

YAML

Here is the YAML that defines this pipeline:

Code Block
breakoutModewide
languagetext
resources:
- repo: self

pool:
  vmImage: Hosted VS2017
  demands:
  - msbuild
  - visualstudio
  - vstest

steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'

- task: VSBuild@1
  displayName: 'Build solution UserStory/UserStory.sln'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: VSTest@2
  displayName: 'VsTest - testAssemblies'
  inputs:
    testAssemblyVer2: |
     **\$(BuildConfiguration)\*test*.dll
     !**\obj\**
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: AzureRmWebAppDeployment@4
  displayName: 'Azure App Service Deploy: tc-dev-user-story'
  inputs:
    azureSubscription: '$(Parameters.connectedServiceName)'
    WebAppName: '$(Parameters.WebAppName)'
    packageForLinux: '$(build.artifactstagingdirectory)/**/*.zip'

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false
  continueOnError: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'