Azure

3 Mins Read

Understanding Different Types of Tasks in Azure Pipelines

Voiced by Amazon Polly

Azure Pipelines, a part of Azure DevOps Services, provides a powerful and flexible way to build, test, and deploy code using continuous integration and continuous delivery (CI/CD). A key feature of Azure Pipelines is its task system, which allows users to define steps in their build and release processes. Tasks are the building blocks of a pipeline, and understanding the different types available can greatly enhance the effectiveness and efficiency of your CI/CD workflows. This blog post explores various types of tasks in Azure Pipelines, with practical examples for each.

1. Build Tasks

Build tasks are used to compile source code, run tests, and produce artifacts. These tasks are essential for transforming source code into deployable packages.

Example: Using the DotNetCoreCLI Task

– task: DotNetCoreCLI@2

inputs:

command: ‘build’

projects: ‘**/*.csproj’

arguments: ‘–configuration Release’

 

In this example, the DotNetCoreCLI task compiles all .csproj files in the repository with the Release configuration. This task is crucial for .NET developers to ensure that their code is compiled correctly before proceeding to the next stages.

Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

2. Testing Tasks

Testing tasks run various types of tests on your code to ensure its quality and functionality. These tasks can run unit tests, integration tests, and more.

Example: Running Unit Tests with the VSTest Task

– task: VSTest@2

inputs:

testSelector: ‘testAssemblies’

testAssemblyVer2: ‘**\*test*.dll’

searchFolder: ‘$(System.DefaultWorkingDirectory)’

codeCoverageEnabled: true

The VSTest task runs unit tests found in the specified assemblies and generates a code coverage report. This task is vital for maintaining code quality and identifying potential issues early in the development process.

3. Packaging Tasks

Packaging tasks create deployable artifacts from your source code. These tasks can package applications, libraries, or other components into formats suitable for deployment.

Example: Packaging with the NuGet Task

– task: NuGetCommand@2

inputs:

command: ‘pack’

packagesToPack: ‘**/*.csproj’

configuration: ‘Release’

 

This NuGet task packages .NET projects into NuGet packages, which can then be published to a NuGet repository. Packaging tasks are essential for preparing your code for deployment or distribution.

4. Deployment Tasks

Deployment tasks automate the process of deploying your applications to various environments, such as Azure, on-premises servers, or other cloud platforms.

Example: Deploying to Azure App Service with the AzureWebApp Task

– task: AzureWebApp@1

inputs:

azureSubscription: ‘$(azureServiceConnection)’

appName: ‘my-web-app’

package: ‘$(Build.ArtifactStagingDirectory)/**/*.zip’

 

In this example, the AzureWebApp task deploys a web application to an Azure App Service. Deployment tasks are critical for automating the release process and ensuring consistent deployments across environments.

5. Utility Tasks

Utility tasks perform various auxiliary operations that support the main build and release processes. These tasks can include operations such as copying files, running scripts, and manipulating variables.

Example: Using the CopyFiles Task

– task: CopyFiles@2

inputs:

SourceFolder: ‘$(Build.SourcesDirectory)’

Contents: ‘**’

TargetFolder: ‘$(Build.ArtifactStagingDirectory)’

 

The CopyFiles task copies files from the source directory to the artifact staging directory. Utility tasks are useful for performing necessary but ancillary operations within your pipelines.

6. Script Tasks

Script tasks allow you to run custom scripts as part of your pipeline. These scripts can be written in various languages, such as PowerShell, Bash, or Python.

Example: Running a PowerShell Script

– task: PowerShell@2

inputs:

targetType: ‘inline’

script: |

Write-Host “Hello, Azure Pipelines!”

# Add your custom script logic here

 

The PowerShell task runs an inline PowerShell script. Script tasks provide flexibility and enable you to perform complex or custom operations within your pipelines.

Conclusion

Azure Pipelines offer a wide variety of tasks that cater to different aspects of the CI/CD process. From building and testing to packaging and deploying, understanding these tasks and their applications can greatly enhance your DevOps workflows. By leveraging the right combination of tasks, you can create efficient, reliable, and automated pipelines that streamline your software development and delivery processes.

Whether you are a seasoned DevOps professional or just getting started with Azure Pipelines, exploring these tasks and incorporating them into your pipelines will help you achieve continuous integration and continuous delivery success.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner,AWS Training Partner,AWS Migration Partner,AWS Data and Analytics Partner,AWS DevOps Competency Partner,Amazon QuickSight Service Delivery Partner,Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners,Amazon EC2 Service Delivery Partner,Amazon ECS Service Delivery Partner,AWS Glue Service Delivery Partner,Amazon Redshift Service Delivery Partner,AWS Control Tower Service Delivery Partner,AWS WAF Service Delivery Partner and many more.

To get started, go through our Consultancy page and Managed Services PackageCloudThat’s offerings.

WRITTEN BY Pramod Sunagar

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!