About the Azure pipeline

Documentation: Doc

Info

Azure Pipelines automatically builds and tests code projects. It supports all major languages and project types and combinesΒ continuous integration,Β continuous delivery, andΒ continuous testingΒ to build, test, and deliver your code to any destination.

How can work with Azure Pipeline ?

Create

center

On the Azure Pipeline, It offers for us some ways to implementation pipelines from multiple resources like

  • YAML pipeline - This flexible way for manage pipeline as code
  • Classic editor - Simple way to making pipeline in Web UI

Customize

On the Infrastructure project, Azure Pipelines are implemented on YAML. If you want to custom them, you should learn

  • Learn how to write YAML file
  • Structure, syntax and workflow of Azure Pipeline. Read more: Azure pipeline definition
  • Use the integration tools on pipelines

For custom your pipeline, choose edit button on the pipeline, you will redirect to YAML editor. You can change the directly to YAML, and click Save with commit message to apply your change

center

On the editor, you can put a hard code variables for your pipeline, It means that variables always use on pipeline. Just click button Variables, create new variables and save.

Run

After create a pipeline like expectation, save it and you can view and manage your pipelines by choosingΒ PipelinesΒ from the left-hand menu to go to the pipelines landing page.

To run the pipeline, select your new pipeline and click button Run Pipeline, It will ask you about Branch should be trigger, if you not set it on pipeline. Choose the branch and click button Run

View your run process, click to the new pipeline, choose Stages and jobs to look the result

Set automation

Click on Setting button, choose Triggers for making schedule

center

Click Add button for create a new schedule

center

Choose the time-zone, day of weeks and source code branch for your schedule

center

Warning

On the first time, you need trigger pipeline and next pipeline will auto execution.

Azure Pipeline features

Agent

Pipeline is simply run the script and It need a machine for doing this stuff, Azure Pipelines provides several different types of agents.

Agent typeDescriptionAvailability
Microsoft-hosted agentsAgents hosted and managed by MicrosoftAzure DevOps Services
Self-hosted agentsAgents that you configure and manage, hosted on your VMsAzure DevOps Services, Azure DevOps Server
Azure Virtual Machine Scale Set agentsA form of self-hosted agents, using Azure Virtual Machine Scale Sets, that can be auto-scaled to meet demandsAzure DevOps Services

Info

Microsoft-hosted agents

Pros: If your pipelines are in Azure Pipelines, then you've got a convenient option to run your jobs using a Microsoft-hosted agent. With Microsoft-hosted agents, maintenance and upgrades are taken care of for you

Cons: Limitation time for free to use. Charge fee for extend running time

Learn more about Microsoft-hosted agents.

Info

Self-hosted agents

An agent that you set up and manage on your own to run jobs is a self-hosted agent. You can use self-hosted agents in Azure Pipelines or Azure DevOps Server, formerly named Team Foundation Server (TFS). Self-hosted agents give you more control to install dependent software needed for your builds and deployments. Also, machine-level caches and configuration persist from run to run, which can boost speed.

Learn more about Self-hosted agents

Info

Azure Virtual Machine Scale Set agents

Azure Virtual Machine Scale Set agents are a form of self-hosted agents that can be auto-scaled to meet your demands. This elasticity reduces your need to run dedicated agents all the time. Unlike Microsoft-hosted agents, you have flexibility over the size and the image of machines on which agents run.

You specify a Virtual Machine Scale Set, a number of agents to keep on standby, a maximum number of virtual machines in the scale set, and Azure Pipelines manages the scaling of your agents for you.

For more information, see Azure Virtual Machine Scale Set agents.

Environment

Overview

Info

An environment is a collection of resources that you can target with deployments from a pipeline. Typical examples of environment names are Dev, Test, QA, Staging, and Production. An Azure DevOps environment represents a logical target where your pipeline deploys software.

Azure DevOps environments aren’t available in classic pipelines. For classic pipelines,Β deployment groupsΒ offer similar functionality.

Create an environment

  1. Sign in to your organization:Β https://dev.azure.com/{yourorganization}Β and select your project.

  2. SelectΒ PipelinesΒ >Β EnvironmentsΒ >Β Create environment.

  3. Enter information for the environment, and then selectΒ Create. Resources can be added to an existing environment later

    center

Target an environment

Use the jobs.deployment.environment for set the value

- stage: deploy
  jobs:
  - deployment: DeployWeb
    displayName: deploy Web App
    pool:
      vmImage: 'Ubuntu-latest'
    # creates an environment if it doesn't exist
    environment: 
      name: 'smarthotel-dev'
      resourceName: myVM
      resourceType: virtualMachine
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo Hello world

Approvals

Manually control when a stage should run using approval checks. Use approval checks to control deployments to production environments. Checks are available to the resource Owner to control when a stage in a pipeline consumes a resource. As the owner of a resource, such as an environment, you canΒ define approvals and checksΒ that must be satisfied before a stage consuming that resource starts.

The Creator, Administrator, and user roles can manage approvals and checks. The Reader role can’t manage approvals and checks.

Security

Check about security in Azure Pipeline Environment Security

Info

You can control who can create, view, use, and manage environments with user permissions. There are four roles: Creator with a scope of all environments, Reader, User, and Administrator.

Library

Info

A library is a collection of build and release assets for an Azure DevOps project. Assets defined in a library can be used in multiple build and release pipelines of the project. The Library tab can be accessed directly in Azure Pipelines.

The library contains two types of assets:Β variable groupsΒ andΒ secure files.

If you want to explore more about how to write and structure yaml of Azure Pipelines, you can check at