Reader small image

You're reading from  Implementing CI/CD Using Azure Pipelines

Product typeBook
Published inDec 2023
PublisherPackt
ISBN-139781804612491
Edition1st Edition
Concepts
Right arrow
Authors (2):
Piti Champeethong
Piti Champeethong
author image
Piti Champeethong

Piti Champeethong is a senior consulting engineer at MongoDB, Singapore. He has been a part of the software development community for over 20 years and specializes in database application development and CI/CD implementation. He is a Microsoft Certified Trainer, lecturer, and community leader. He lives in Thailand and engages with Thai tech communities, such as the MongoDB Thailand User Group and the Thailand .NET community by speaking at various events. He has made significant contributions to public repositories on .NET and MongoDB technologies, supporting the growth of the Thai tech community.
Read more about Piti Champeethong

Roberto Mardeni
Roberto Mardeni
author image
Roberto Mardeni

Roberto Mardeni has been working in the IT industry for over two decades. He specializes in software development, architecture, and DevSecOps practices around many different application platforms and CI/CD tools, typically focusing on Microsoft .NET and other open source programming languages. He has been working since 2017 as an application innovation specialist on the enterprise sales side at Microsoft, supporting their cloud business. He lives in the United States and helps some of the largest independent software vendors to adopt the Azure platform. This is his first foray into technical writing, but he has contributed to the open source community in different GitHub public repositories of his own and contributed to others as well.
Read more about Roberto Mardeni

View More author details
Right arrow

Implementing the Build Pipeline Using Deployment Tasks

In the previous chapter, we created a pipeline using YAML, and we learned the process of creating jobs and tasks in the YAML format and exporting and importing a build pipeline. This chapter will dive deep into creating a pipeline using standard tasks. By the end of this chapter, you will have learned how to create a build pipeline for web application development, including Node.js, .NET Core, Docker, and Microsoft SQL Server, both on-premises and in Azure, using beginner-friendly tasks that make it easy to understand the concept.

We will cover the following topics:

  • Working with Node.js and Node Package Manager (NPM) tasks
  • Working with .NET Core CLI tasks
  • Working with Docker tasks
  • Working with SQL Server deployment tasks

Let’s start by learning how to create a pipeline using Node.js and NPM tasks.

Working with Node.js and NPM tasks

You need to use Node.js and NPM commands to build and deploy Node.js applications. There are many predefined tasks to build such applications in an Azure pipeline. Follow these steps to create a pipeline using Node.js and NPM tasks:

  1. After logging in to the Azure DevOps portal, select your organization, navigate to the Pipelines page, and click on New pipeline:

Figure 5.1 – A new pipeline

Figure 5.1 – A new pipeline

  1. Select Azure Repos Git, which is a source code repository for this demo:

Figure 5.2 – Selecting Azure Repos Git

Figure 5.2 – Selecting Azure Repos Git

  1. Select the PacktAzureDevOps repository that we created in Chapter 2:
Figure 5.3 – Selecting a repository

Figure 5.3 – Selecting a repository

  1. Click on Show more:

Figure 5.4 – Showing more tasks

Figure 5.4 – Showing more tasks

  1. Select the Node.js option:

Figure 5.5 – Selecting Node.js

Figure 5.5 – Selecting Node...

Working with .NET Core CLI tasks

For .NET applications, you must use .NET Core CLI commands to build and deploy .NET applications. There are many predefined tasks to build .NET applications in an Azure pipeline. Follow these steps to create a pipeline using .NET Core CLI tasks:

  1. Follow steps 1 to 3 from the previous section for Node.js and NPM tasks.
  2. Select Starter pipeline:
Figure 5.8 – Selecting the Starter pipeline option

Figure 5.8 – Selecting the Starter pipeline option

  1. Rename the file from the default name to make it easier to understand what the YAML file is for:

Figure 5.9 – Renaming a pipeline file

Figure 5.9 – Renaming a pipeline file

  1. Select the Use .NET Core task and click Add:
Figure 5.10 – Selecting the Use .NET Core task

Figure 5.10 – Selecting the Use .NET Core task

  1. Update the version property to use .NET 6:

Figure 5.11 – Updating the .NET version

Figure 5.11 – Updating the .NET version

  1. Select the .NET Core task and click on Add:
...

Working with Docker tasks

For cloud-native applications, you need to use Docker commands to build and deploy cloud-native applications. There are many predefined tasks for building cloud-native applications in an Azure pipeline. You can perform the following steps to create a pipeline using Docker tasks:

  1. Follow steps 1 to 4 as described in the previous section for .NET Core CLI tasks.
  2. Rename the file for the Docker pipeline:
Figure 5.14 – Renaming the file

Figure 5.14 – Renaming the file

  1. Select the Docker CLI installer task, click on Add, and update DockerInstaller@0:
    - task: DockerInstaller@0
      inputs:
        dockerVersion: '17.09.0-ce'

    The following screenshot shows you how to add a Docker CLI installer task and fill in the details on this task:

Figure 5.15 – Adding a Docker CLI installer task

Figure 5.15 – Adding a Docker CLI installer task

  1. Select the Docker task and click on Add, and you will see the following code. This...

Working with SQL Server deployment tasks

You need to use SQL Server commands to build and deploy SQL Server applications. There are many tasks that need to be completed to build SQL Server applications in Azure Pipelines; follow these steps to create a pipeline using SQL Server deployment tasks:

  1. You can follow steps 1 to 4 as described in the Working with .NET Core CLI tasks section.
  2. Rename the file as shown in the following screenshot:
Figure 5.18 – Renaming the file

Figure 5.18 – Renaming the file

  1. Search for SQL Server database, select the SQL Server database deploy task, and enter the following:
    - task: SqlDacpacDeploymentOnMachineGroup@0
      inputs:
        TaskType: 'sqlQuery'
        SqlFile: 'migrate.sql'
        ExecuteInTransaction: true
        ServerName: 'localhost'
        DatabaseName: 'your_database'
       ...

Summary

This chapter taught you how to build and release pipelines, using standard NPM, the .NET Core CLI, Docker, and SQL Server deployment tasks. These predefined tasks are popular for building and deploying Node.js and .NET applications. They reduce the time spent by developers creating manual commands when running a pipeline to build those applications.

In the next chapter, you will learn in depth about integrating testing and security tasks to make your code and applications more reliable.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Implementing CI/CD Using Azure Pipelines
Published in: Dec 2023Publisher: PacktISBN-13: 9781804612491
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (2)

author image
Piti Champeethong

Piti Champeethong is a senior consulting engineer at MongoDB, Singapore. He has been a part of the software development community for over 20 years and specializes in database application development and CI/CD implementation. He is a Microsoft Certified Trainer, lecturer, and community leader. He lives in Thailand and engages with Thai tech communities, such as the MongoDB Thailand User Group and the Thailand .NET community by speaking at various events. He has made significant contributions to public repositories on .NET and MongoDB technologies, supporting the growth of the Thai tech community.
Read more about Piti Champeethong

author image
Roberto Mardeni

Roberto Mardeni has been working in the IT industry for over two decades. He specializes in software development, architecture, and DevSecOps practices around many different application platforms and CI/CD tools, typically focusing on Microsoft .NET and other open source programming languages. He has been working since 2017 as an application innovation specialist on the enterprise sales side at Microsoft, supporting their cloud business. He lives in the United States and helps some of the largest independent software vendors to adopt the Azure platform. This is his first foray into technical writing, but he has contributed to the open source community in different GitHub public repositories of his own and contributed to others as well.
Read more about Roberto Mardeni