Use versioned artifacts — keep your last working package and redeploy it. Example: If your new API build breaks production, you can quickly redeploy the previous successful release version from Azure DevOps → Releases → “Redeploy”. 8⃣ How do you deploy infrastructure using ARM templates or Bicep in Azure DevOps?
You can deploy Infrastructure as Code (IaC) directly from your pipeline using ARM or
Bicep files.
Follow:
Example (YAML):
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'MyServiceConnection'
subscriptionId: 'xxxx-xxxx-xxxx'
action: 'Create Or Update Resource Group'
resourceGroupName: 'my-rg'
location: 'East US'
templateLocation: 'Linked artifact'
csmFile: 'infrastructure/main.bicep'
overrideParameters: '-appName myapp -sku S1'
Example scenario:
Before deploying your .NET app, your pipeline provisions a new App Service, SQL
Database, and Storage Account automatically.
9⃣ How can you use Azure CLI or PowerShell tasks in your release
pipeline?
You can run custom scripts using AzureCLI@2 or PowerShell@2 tasks to automate
advanced tasks.
Example (Azure CLI):
- task: AzureCLI@2
inputs:
azureSubscription: 'MyServiceConnection'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az webapp restart --name my-webapp --resource-group my-rg
Example (PowerShell):
- task: PowerShell@2
Follow:
inputs:
targetType: 'inline'
script: |
Write-Host "Performing custom cleanup..."
Remove-Item -Path $(Build.ArtifactStagingDirectory)\temp
- Recurse -Force
Example scenario:
After deploying your app, you might use a PowerShell script to clear old log files or an Azure
CLI command to restart the web app.
✅ Pro Tip:
A solid Release Pipeline usually includes:
- Staged deployments (Dev → QA → Prod)
- Environment-specific configs
- Pre-deployment approvals
- Slot-based zero-downtime deployment
- Rollback and infrastructure provisioning
Testing & Quality
1⃣ How do you integrate unit tests, integration tests, or UI tests in Azure
Pipelines?
You can run all types of automated tests (unit, integration, UI) inside your build or release
pipelines using tasks like DotNetCoreCLI@2, Visual Studio Test@2, or custom
scripts.
Example (Unit Tests):
- task: DotNetCoreCLI@2
inputs:
Follow:
command: 'test'
projects: '**/*UnitTests.csproj'
publishTestResults: true
Example (Integration Tests):
- Typically run after the app is deployed to a test environment.
- You can use a task like:
- script: dotnet test
./Tests/IntegrationTests/IntegrationTests.csproj
Example (UI Tests):
- Tools like Selenium or Playwright can be integrated as post-deployment steps in
your pipeline:
- script: npx playwright test
Real-life scenario:
After building a .NET API, the pipeline runs unit tests.
Then, in a release pipeline, once the app is deployed to the “QA” environment, Selenium
tests verify that the login screen works.
2⃣ What is code coverage, and how do you view it in Azure DevOps?
Code coverage measures how much of your code is executed during tests — it helps you
see which parts of your application aren’t tested.
Example (for .NET):
- script: dotnet test --collect:"XPlat Code Coverage"
This generates a coverage report (coverage.cobertura.xml), which Azure DevOps can
display in the Test Results → Code Coverage tab.
Follow:
Example scenario:
Your pipeline might show that 82% of your code is covered by tests.
You can then aim to increase that by adding more unit tests for uncovered modules.
3⃣ How do you use SonarQube or other tools for static code analysis?
SonarQube checks your code for bugs, code smells, and security vulnerabilities.
Integration steps: