Modify the YAML as needed. Example (YAML): trigger: - main pool: vmImage: 'windows-latest' steps: - task: UseDotNet@2 inputs: packageType: 'sdk' version: '8.0.x' - script: dotnet restore - script: dotnet build --configuration Release - script: dotnet test --no-build --verbosity normal This pipeline restores packages, builds, and runs tests for your .NET app. 5⃣ What tasks are commonly used in .NET build pipelines?
Common tasks:
- UseDotNet@2 → Installs .NET SDK.
- NuGetCommand@2 → Restores NuGet packages.
Follow:
- DotNetCoreCLI@2 → Builds, tests, and publishes your app.
- PublishBuildArtifacts@1 → Stores your compiled output.
Example:
A .NET Core pipeline may use:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
6⃣ How do you restore NuGet packages in a build pipeline?
Use either:
- script: dotnet restore
- task: NuGetCommand@2
inputs:
command: 'restore'
This pulls dependencies from NuGet.org or an internal feed.
Example:
If your project uses private packages, you can add a NuGet service connection or Azure
Artifacts feed to authenticate.
7⃣ How do you run unit tests and publish test results in a pipeline?
You use the DotNetCoreCLI@2 task with test command and publish results.
Example (YAML):
Follow:
- task: DotNetCoreCLI@2
inputs:
command: 'test'
projects: '**/*Tests.csproj'
publishTestResults: true
Azure Pipelines will then display test results (passed, failed, duration) in the build summary.
8⃣ What is the purpose of the dotnet build, dotnet test, and dotnet
publish commands in pipelines?
- dotnet build → Compiles your code and checks for errors.
- dotnet test → Runs all your unit tests.
- dotnet publish → Packages your app for deployment (e.g., to Azure Web App).
Example:
In a pipeline:
- script: dotnet build
- script: dotnet test
- script: dotnet publish -c Release -o
$(Build.ArtifactStagingDirectory)
The final publish step outputs deployable files like .dll or .zip.
9⃣ How do you create and publish build artifacts?
Artifacts are the build outputs you want to use later (for deployment or testing).
Example (YAML):
Follow:
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
This publishes your compiled files to Azure DevOps, where the Release pipeline can pick
them up.
🔟 What are pipeline variables and variable groups?
Pipeline variables: Key-value pairs you define in the pipeline or YAML.
variables:
buildConfig: 'Release'
- Variable groups: Collections of variables shared across pipelines (e.g., API keys,
environment names).
Example:
If multiple pipelines need the same database connection string, store it in a variable group
called ProdSettings.
11⃣ What are pipeline templates and how are they used?
Templates let you reuse pipeline steps across projects — great for standardization.
Example:
You can create a reusable file:
📄 .azure-pipelines/build-template.yml
steps:
- script: dotnet restore
- script: dotnet build
Follow:
Then in your main pipeline:
extends:
template: .azure-pipelines/build-template.yml
This keeps your YAML DRY (Don’t Repeat Yourself) and consistent.
12⃣ How do you handle secrets in pipelines (Azure Key Vault integration)?
You never store passwords directly in YAML — instead, use Azure Key Vault or variable
groups linked to Key Vault.
Example:
- Create a Key Vault in Azure.
- Add secrets like SqlPassword.
- In pipeline, add Key Vault as a variable group.
YAML:
variables:
- group: MyKeyVaultVariables
Secrets are pulled securely during build and never exposed in logs.
13⃣ How do you implement pipeline caching for NuGet packages or
intermediate files?
Caching helps speed up builds by reusing downloaded packages or build outputs.
Example (YAML):
- task: Cache@2
inputs:
Follow:
key: 'nuget | "$(Agent.OS)" | packages.lock.json'
path: ~/.nuget/packages
restoreKeys: |
nuget | "$(Agent.OS)"
This caches your NuGet packages, so they don’t have to be re-downloaded every build —
often cutting build time in half.
✅ Pro Tip:
A well-designed .NET CI pipeline in Azure DevOps usually includes:
- Code checkout
- dotnet restore
- dotnet build
- dotnet test
- Artifact publishing
- Optional: static code analysis, SonarQube, or code coverage tools
Release Pipelines (CD)
1⃣ What is a release pipeline and how does it differ from a build pipeline?
A build pipeline (CI) compiles, tests, and packages your code — it produces artifacts.
A release pipeline (CD) takes those artifacts and deploys them to different environments
like Dev, QA, or Production.
Example:
- Build Pipeline: Compiles your .NET app and outputs a .zip file.
Follow:
- Release Pipeline: Takes that .zip and deploys it to Azure App Service.
So, the build pipeline = create, and release pipeline = deliver.
2⃣ What are deployment stages and environments in Azure DevOps?
A stage represents a step in your release process — like Dev, QA, UAT, or Production.
An environment is the actual target (Azure Web App, VM, Kubernetes cluster, etc.) where
your app is deployed.
Example:
A release pipeline might have:
- Stage 1 – Dev: Deploy automatically for testing.
- Stage 2 – QA: Deploy after QA team approval.
- Stage 3 – Prod: Deploy after manager approval.
Each stage can target a different Azure App Service or resource group.
3⃣ How do you configure approvals and gates for releases?
Approvals and gates ensure deployments happen safely — with the right people’s
permission or automated checks.
Approvals:
- Manual approvals before a stage starts or after it finishes.
- You can assign specific approvers (e.g., QA lead for QA, Manager for Prod).
Gates:
- Automated checks before deployment continues — like monitoring alerts, querying
Azure Monitor, or checking work item states.
Follow:
Example:
Before deploying to Production:
- Require approval from a “Release Manager”.
- Add a gate to check if the app’s error rate in Application Insights is below 2%.
4⃣ How do you deploy a .NET web app to Azure App Service using Azure
Pipelines?
You can deploy using the Azure Web App Deploy task.
Example (YAML):
- task: AzureWebApp@1
inputs:
azureSubscription: 'MyServiceConnection'
appName: 'my-dotnet-webapp'
package: '$(Pipeline.Workspace)/drop/**/*.zip'
Steps: