Skip to main content

First Azure Pipeline

Pipeline

source: Ms

I wanted to create a CI/CD pipeline in azure and I spent some time "googling" till i found 2 tutorials that were clear and helped me to create my first pipeline on Azure.

I wanted to to

  1. Automatically create infrastructure in Azure using bicep
  2. Automatically deploy Azure function running on App Service Plan

I came across a 43 minutes Microsoft Tutorial that helped me to deploy my function.

I also followed a Deploy Azure Functions with Azure DevOps YAML Pipelines by Wolfgang Ofner.

Below sections highlights key points I learned from this tutorials.

Microsoft Tutorial

Link: Build your first Bicep deployment pipeline by using Azure Pipelines

The tutorial starts with pre-requisites & covers key points about Azure pipelines including:

  • Pipeline : A pipeline is the repeatable process that you use to test and deploy your code defined in a configuration file

  • Agent: A computer used by pipeline to execute deployment steps. The agents sometimes are called Microsoft-hosted agents or hosted agents because they're hosted on your behalf

  • Agent Pool: for a lack of better explanation, a pool of "same type" agents. When running a pipeline, it waits for agent from pool to be available before execution. You can choose to run self-hosted agent if you have special software needs.

  • Sevice Connection: Required to deploy bicep files to azure. When we deploy bicep locally, we go through az login process to authenticate. Because the manual authentication process does not exist in pipelines, we need to use Service Connection. Service Connection securely stores the service principal's credentials (Application ID & Secret) so that the pipeline can use them to authenticate.

Pipeline Example

trigger:
branches:
include:
- main
- release/*
exclude:
- feature/*
paths:
exclude:
- docs
- design
include:
- deploy/ci-cd-pipeline.yml
- bicep

pool:
vmImage: ubuntu-latest

jobs:
- job:
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'

- script: |
echo We'll add more steps soon.
echo For example, we'll add our Bicep deployment step.
displayName: 'Run a multi-line script'

Source: MS

  • trigger: instructs pipeline when to run a pipeline. none is manual. The fact that you can include or exclude branches, folders and files is super cool. In this example, only main & release branches are included. When docs & design is updated, the pipeline won't execute.
  • pool: instructs pipeline which pool to use. You can choose between linux & win pools
  • jobs: Groups all the jobs in the pipeline. Its optional if you have only one job
  • job: container with sequence of steps to execute. Its optional if you have only one job
  • steps: Sequence of actions to be executed by the job. In this example, text is echod' & display name is the title of the step visible in the portal. Each step is the same as commands we run on bash or powershell. There are 2 types of steps, script & task.

Wolfgang Tutorial

Link: Deploy Azure Functions with Azure DevOps YAML Pipelines

Once you understand the basics outlined in the above tutorial, this blog post looks straight forward. The sample follows below steps

  1. Build Solution
  2. Publish Solutino
  3. Deploy Azure function
  4. Update App Settings