You will need a GitHub account as well as basic knowledge of Git for forking, committing, and pushing code within a repository. If you do not already have a GitHub account, you can sign up at GitHub.com
To learn about Azure DevOps you will need an Azure DevOps account. If you do not already have an Azure DevOps account, you can sign up at azure.microsoft.com/services/devops; the free tier is sufficient for this workshop.
In addition to an Azure DevOps account, an Azure subscription is also recommended. An Azure subscription will be used to host deployed websites and working with release management, continuous delivery, and continuous deployment. If needed, sign up at azure.microsoft.com/services/app-service. Note: the signup process will ask you for a phone number and credit card for identity verification, but you will not be charged unless you change your subscription tier.
Within your Azure Subscription, create two free-tier Azure App Service Application instances to simulate Test and Production environments.
Ours are called workshop-dev
and workshop-prod
.
- Fork the Sample Code: https://github.com/aranasoft/learn-azureDevOps
This workshop is not about building a new website in some various technology, but instead on automation for building, testing, and deploying and application using Azure DevOps. This code project, little more than a default template for an AspNetCore web project, will provide a baseline application for the workshop. Forking this repository allow you to make modifications to the codebase and commits to the repository to learn the fundamentals and workflow of continuous integration, delivery, and deployment.
- Create a new pipeline
- Repository: GitHub with a Personal Access Token
- Pipeline: Rename. Set Agent pool to
Azure Pipelines
and a specification ofubuntu-16.04
- Agent Job: Rename
- Create a variable
BuildConfiguration
set toRelease
- Add a
.NET Core
Task. Command: Restore. - Add a
.NET Core
Task. Command: Build. Args:--no-restore --configuration $(BuildConfiguration)
- Save and Queue
- Edit pipeline
- Add a
.NET Core
Task. Command: Test. Path:*.tests/*.tests.csproj
Arg:--no-restore --no-build --configuration $(BuildConfiguration)
- Save and Queue
A purely human element, this is a task that cannot be governed with automation.
- Edit pipeline; Go to the Triggers tab
- Enable continuous integration. Do not batch changes
- Enable for all branches
- Enable Pull Request validation
- Enable a scheduled build for 1:00am, every day.
- Create a
PowerShell Script
task, inline script. Code: http://bit.ly/branchQuality - Save and Queue
- Go to Project Settings; Notifications tab
- Add a new Subscription for Changed By when Build Fails
- Edit pipeline; Go to the Options tab
- Add the Badge to your README.md; commit
- Save and Queue
- Edit pipeline; Go to the Tasks tab
- Set the Timeout for the Build task to 5 minutes.
- Set the Timeout for the Job to 10 minutes.
- Save and Queue
- Add a
.NET Core
Task. Command: Publish. Zip with Path. Publish Web Projects. Arg:--no-restore --no-build --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)
- Add a
Publish Build Artifacts
Task. - Save and Queue
- Create a new Release Pipeline
- Create a new Release Artifact from your Build Pipeline
- Enable the Artifact's Continuous Deployment Trigger
- Create a
Test
Stage. Enable theAfter Release
Trigger - Create an
Azure App Service Deploy
task from yourlearn-azureDevOps.zip
package to your subscription'sworkshop-dev
instance - Save; trigger a build
- Edit the Release pipeline
- Clone the Test stage; rename cloned stage to Production
- Enable Production pre-deployment After Stage trigger
- Enable Production pre-deployment approvals
- Modify Production job deploy task to use
workshop-prod
- Save; trigger a build :ne
With an understanding of Azure DevOps using the classic interface, rebuilding the pipelines in YAML allows the source repository to manage its own build configuration.
- Create an empty-pipeline file
- Connect the file to Azure DevOps
- Add
DotNetCoreCLI@2
tasks for Restore, Build, & Test - Add
BuildConfiguration
queue variable - Save
- Edit pipeline
- Wrap existing steps in a job
- Create Publishing steps within existing job
- Save
- Edit pipeline
- Add a branch trigger to the pipeline
- Add a pr trigger to the pipeline
- Add a cron trigger to the pipeline
- Save
- Enable Multi-Stage Feature
- Add a Service Connection to your Subscription
- Wrap all existing jobs in a Build Stage
- Add a new Deployment Stage, with a Deployment Job to Test
- Save
- Add a Production environment
- Configure Production for Pre-Stage Approvals
- Edit Pipeline
- Add Stage for Production Deployment
- Add branch condition to Production Deployment stage:
and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/master'))
- Save