Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ In this task, you will create an Azure web app and an Azure SQL database by usin

In this exercise, you will configure CI/CD Pipelines as code with YAML in Azure DevOps.

#### Task 1: Disable execution of the existing pipeline
#### Task 1: Delete the existing pipeline

In this task, you will disable execution of the existing pipeline.
In this task, you will delete the existing pipeline.

1. On the lab computer, switch to the browser window displaying the **Configuring Pipelines as Code with YAML** project in the Azure DevOps portal and, in the vertical navigational pane, select the **Pipelines**.

> **Note**: Before configuring YAML pipelines, you will disable the existing build pipeline.

1. On the **Pipelines** pane, select the **PartsUnlimited** entry.
1. In the upper right corner of the **PartsUnlimited** blade, click the vertical ellipsis symbol and, in the drop-down menu, select **Settings**.
1. On the **Pipeline settings** pane, select the **Paused** option.
1. In the upper right corner of the **PartsUnlimited** blade, click the vertical ellipsis symbol and, in the drop-down menu, select **Delete**.
1. Write **PartsUnlimited** and click **Delete**.

#### Task 2: Add a YAML build definition

Expand All @@ -143,6 +143,10 @@ In this task, you will add a YAML build definition to the existing project.

> **Note**: The pipeline definition will be saved as a file named **azure-pipelines.yml** in the root of the repository. The file will contain the steps required to build and test a typical ASP.NET solution. You can also customize the build as needed. In this scenario, you will update the **pool** to enforce the use of a VM running Visual Studio 2017.

1. Change `trigger` to **master**.

> **Note**: Review in Repos if your repository has **master** or **main** branch, new repos will be having **main** by default.

1. On the **Review your pipeline YAML** pane, in line **10**, replace `vmImage: 'windows-latest'` with `vmImage: 'vs2017-win2016'`.
1. On the **Review your pipeline YAML** pane, click **Save and run**.
1. On the **Save and run** pane, accept the default settings and click **Save and run**.
Expand Down Expand Up @@ -204,17 +208,17 @@ In this task, you will add continuous delivery to the YAML-based definition of t

> **Note**: By default, these two stages run independently. As a result, the build output from the first stage might not be available to the second stage without additional changes. To implement these changes, we will use one task to publish the build output at the end of the build stage and another to download it in the beginning of the deploy stage.

1. Place the cursor on a blank line at the end of the build stage.
1. Place the cursor on a blank line at the end of the build stage to add another task. (right below `task: VSTest@2` )
1. On the **Tasks** pane, search for and select the **Publish build artifacts** task.
1. On the **Publish build artifacts** pane, accept the default settings and click **Add**.

> **Note**: This will publish the build artifacts to a location that will be downloadable under the alias **drop**.

1. With the added task still selected in the editor, press the **Tab** key twice to indent it four spaces.
1. With the added task still selected in the editor, press the **Tab** key twice to indent it four spaces (or press the **Tab** until task is indented as the ones above).

> **Note**: You may also want to add an empty line before and after to make it easier to read.

1. Place the cursor on the first line under the **steps** node of the deployment stage.
1. Place the cursor on the first line under the **steps** node of the **deploy** stage.
1. On the **Tasks** pane, search for and select the **Download build artifacts** task.
1. Click **Add**.
1. With the added task still selected in the editor, press the **Tab** key twice to indent it four spaces.
Expand All @@ -231,12 +235,73 @@ In this task, you will add continuous delivery to the YAML-based definition of t

> **Note**: This will automatically trigger a new build.

1. The pipeline will look similar to this example (poiting to your own subscription and webapp):

```
trigger:
- master

stages:
- stage: Build
jobs:
- job: Build
pool:
vmImage: 'vs2017-win2016'

variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'

- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'

- stage: Deploy
jobs:
- job: Deploy
pool:
vmImage: 'vs2017-win2016'
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
downloadPath: '$(System.ArtifactsDirectory)'
artifactName: 'drop'
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'YOUR-AZURE-SUBSCRIPTION'
appType: 'webApp'
WebAppName: 'YOUR-WEBAPP-NAME'
packageForLinux: '$(System.ArtifactsDirectory)/drop/*.zip'
```

1. In the web browser window displaying the Azure DevOps portal, in the vertical navigational pane, select the **Pipelines**.
1. On the **Pipelines** pane, click the entry representing the newly configured pipeline.
1. In the in the upper right corner of the **PartsUnlimited** pipeline pane listing its runs, click the vertical ellipsis symbol and, in the drop-down menu, select **Settings**.
1. On the **Pipeline settings** pane, in the **YAML file path** dropdown list, select the **./azure-pipelines-1.yml** entry, right above it, select the **Enabled** option, and click **Save**.
1. Back on the **PartsUnlimited** pipeline pane listing its runs, in the vertical navigational pane, select the **Pipelines**.
1. On the **Pipelines** pane, hover with the mouse pointer over the entry representing the newly configured pipeline so it reveals the ellipsis symbol on the right side, click the ellipsis symbol, and, in the drop-down menu, select **Run pipeline**.
1. On the **Pipelines** pane, click the entry representing the newly configured pipeline.
1. Click on the most recent run (automatically started).
1. On the **Summary** pane, monitor the progress of the pipeline run.
1. If you notice a message stating that *This pipeline needs permissions to access a resource before this run can continue to Deploy*, click **View**, in the **Waiting for review** dialog box, click **Permit**, and, in the **Permit access?** pane, click **Permit** again.
1. At the bottom of the **Summary** pane, click the **Deploy** stage to view details of the deployment.
Expand Down