Friday, July 31, 2026

Azure DevOps

Microsoft Azure DevOps official documentation

Azure DevOps — Complete Guide for .NET Lead

1. What is Azure DevOps?

Azure DevOps is a set of services for planning, developing, testing, deploying, and monitoring software.

Think of a typical .NET project:

Developer
    |
    v
Write C# Code
    |
    v
Git Repository
    |
    v
Build
    |
    v
Unit Tests
    |
    v
Code Quality
    |
    v
Deploy to DEV
    |
    v
Testing
    |
    v
Deploy to QA
    |
    v
Deploy to Production
    |
    v
Azure Monitor / Application Insights

Azure DevOps helps automate this entire process.


2. Main Azure DevOps Services

You should remember these:

Azure DevOps
    |
    +-- Azure Repos
    |
    +-- Azure Pipelines
    |
    +-- Azure Boards
    |
    +-- Azure Test Plans
    |
    +-- Azure Artifacts

Easy way to remember

ServicePurpose
Azure ReposSource Code
Azure PipelinesCI/CD
Azure BoardsWork Management
Azure Test PlansTesting
Azure ArtifactsPackage Management

3. Real-Time Project

Let's take a real enterprise application:

Angular Frontend
       |
       v
ASP.NET Core Web API
       |
       +---- Azure SQL
       |
       +---- Azure Service Bus
       |
       +---- Azure Functions
       |
       +---- Azure Storage

Developers work on:

C#
Angular
SQL
Azure

Now imagine 10 developers working on the same project.

Azure DevOps provides the platform for:

Planning
   ↓
Coding
   ↓
Pull Request
   ↓
Review
   ↓
Build
   ↓
Unit Tests
   ↓
Security/Quality checks
   ↓
Deployment
   ↓
Monitoring

4. Azure Repos

Azure Repos provides Git repositories for source control.

Example:

MyCompany
   |
   +-- OrderManagement
   |
   +-- PaymentService
   |
   +-- InventoryService

You can use:

git clone
git pull
git push
git branch
git merge

just like other Git hosting platforms.


5. Typical Git Workflow

Suppose you are developing an Order API.

You shouldn't directly modify the production branch.

Instead:

main
 |
 +---- feature/order-api

Developer:

git checkout -b feature/order-api

Develop code:

OrderController.cs
OrderService.cs
OrderRepository.cs

Then:

git add .
git commit -m "Add order API"
git push origin feature/order-api

Then create:

Pull Request

6. Pull Request

The PR process is very important for a Lead.

Developer
    |
    v
Feature Branch
    |
    v
Pull Request
    |
    +---- Code Review
    +---- Build
    +---- Unit Tests
    +---- Quality Checks
    |
    v
Approve
    |
    v
Merge

A Lead should establish policies such as:

  • Minimum reviewers

  • Build validation

  • Linked work items

  • No direct pushes to main

  • Required checks

  • Branch naming conventions


7. Branching Strategy

For many enterprise projects:

main
 |
 +-- develop
      |
      +-- feature/order
      |
      +-- feature/payment
      |
      +-- bugfix/order

Another common approach is trunk-based development:

main
 |
 +-- short-lived feature branch
 |
 +-- short-lived feature branch
 |
 +-- short-lived feature branch

Lead-level point

Don't say:

"Git Flow is always the best."

Instead:

"I choose the branching strategy based on release frequency, team size, deployment model, and whether we use feature flags or continuous delivery."

That's a stronger architectural answer.


8. Azure Boards

Azure Boards is used to manage work.

Typical hierarchy:

Epic
  |
  +-- Feature
        |
        +-- User Story
              |
              +-- Task
              +-- Bug

Example:

Epic:
E-Commerce Platform

Feature:
Order Management

User Story:
As a customer, I want to place an order.

Tasks:
- Create Order API
- Create Order table
- Add validation
- Write unit tests
- Create Angular UI

9. Agile Sprint

Example:

Sprint 1
------------------------
Order API
Payment API
Login
Customer API

Azure Boards helps track:

To Do
   ↓
In Progress
   ↓
Code Review
   ↓
Testing
   ↓
Done

10. Azure Pipelines

This is probably the most important Azure DevOps feature for a .NET Lead.

Azure Pipelines automates:

Build
Test
Package
Deploy

This is called CI/CD.


11. What is CI?

Continuous Integration

Developers frequently merge code into the shared repository.

Every change triggers:

Git Push
   ↓
Pipeline
   ↓
Restore
   ↓
Build
   ↓
Unit Test
   ↓
Quality Checks

If build/test fails:

Pipeline FAILED

The developer fixes it before the change progresses.


12. What is CD?

Continuous Delivery/Deployment

After successful CI:

Build
   ↓
Test
   ↓
Deploy DEV
   ↓
Deploy QA
   ↓
Approval
   ↓
Deploy Production

13. Complete CI/CD Pipeline

For a .NET application:

                    Developer
                        |
                        v
                   Azure Repos
                        |
                        v
                   Pull Request
                        |
                        v
                 Build Validation
                        |
             +----------+----------+
             |                     |
             v                     v
         dotnet build         dotnet test
             |                     |
             +----------+----------+
                        |
                        v
                  Create Artifact
                        |
                        v
                     DEV
                        |
                        v
                  Integration Test
                        |
                        v
                     QA
                        |
                        v
                  Approval/Gate
                        |
                        v
                   Production
                        |
                        v
               Application Insights

This is a very strong diagram to explain during interviews.


14. Azure Pipeline YAML

A basic .NET pipeline can look like:

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '9.x'

- script: dotnet restore
  displayName: 'Restore'

- script: dotnet build --configuration $(buildConfiguration) --no-restore
  displayName: 'Build'

- script: dotnet test --configuration $(buildConfiguration) --no-build
  displayName: 'Run Unit Tests'

- script: dotnet publish \
          --configuration $(buildConfiguration) \
          --output $(Build.ArtifactStagingDirectory)
  displayName: 'Publish'

- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: 'drop'

The exact task versions and recommended YAML patterns can evolve, so use Microsoft's current task documentation when building a production pipeline.

Azure Pipelines documentation


15. Let's Understand the Pipeline

Step 1 — Trigger

trigger:
- main

Means:

Run the pipeline when changes are pushed to main.


Step 2 — Agent

pool:
  vmImage: 'ubuntu-latest'

Azure DevOps provides an agent to execute pipeline steps.

Conceptually:

Azure DevOps
     |
     v
Build Agent
     |
     +-- Restore
     +-- Build
     +-- Test
     +-- Publish

16. Restore

- script: dotnet restore

Restores NuGet dependencies.


17. Build

- script: dotnet build --configuration Release

Compiles the application.

If C# has errors:

Build FAILED

The deployment doesn't continue.


18. Unit Testing

- script: dotnet test

Suppose:

100 Tests
98 Passed
2 Failed

Pipeline:

FAILED

This prevents broken code from moving forward.


19. Publish

dotnet publish

Creates deployable output.

Conceptually:

Source Code
    ↓
Build
    ↓
Publish
    ↓
Artifact

20. What is an Artifact?

An artifact is the output produced by the build that can be used later by deployment stages.

Example:

Build
  |
  v
drop.zip

Then:

drop.zip
   |
   +---- DEV
   |
   +---- QA
   |
   +---- PROD

A key Lead-level principle is:

Build once, deploy the same artifact through environments.

You don't want to rebuild differently for production.


21. Multi-Stage Pipeline

A better enterprise pipeline:

stages:

- stage: Build
  jobs:
  - job: Build
    steps:
    - script: dotnet restore

    - script: dotnet build --configuration Release

    - script: dotnet test --configuration Release

    - script: dotnet publish \
              --configuration Release \
              --output $(Build.ArtifactStagingDirectory)

    - publish: $(Build.ArtifactStagingDirectory)
      artifact: drop


- stage: DeployDev
  dependsOn: Build
  jobs:
  - deployment: Deploy
    environment: Dev
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop


- stage: DeployQA
  dependsOn: DeployDev
  jobs:
  - deployment: Deploy
    environment: QA
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop

This demonstrates the concept:

Build
 ↓
Artifact
 ↓
DEV
 ↓
QA
 ↓
PROD

22. Environments

Azure DevOps environments represent deployment targets such as:

DEV
QA
UAT
PROD

Example:

Build
 |
 v
DEV
 |
 v
QA
 |
 v
UAT
 |
 v
PROD

23. Production Approval

Suppose your pipeline reaches:

Deploy Production

You can require an approval:

Pipeline
   |
   v
Production
   |
Approval required
   |
   v
Manager/Lead approves
   |
   v
Deployment

This is important for controlled enterprise releases.


24. Variable Groups

Don't hard-code environment configuration into YAML.

Bad:

SqlConnectionString: "Server=..."

Instead, use variables/configuration mechanisms.

Example:

Variable Group
      |
      +-- Dev
      +-- QA
      +-- Prod

Then:

DEV → Dev configuration
QA  → QA configuration
PROD → Prod configuration

For sensitive secrets, prefer Azure Key Vault integration rather than plain pipeline variables wherever appropriate.


25. Azure Key Vault + Azure DevOps

A strong enterprise architecture:

Azure DevOps Pipeline
       |
       v
Azure Key Vault
       |
       +---- SQL connection information
       +---- API secrets
       +---- Certificates
       +---- Other secrets

The pipeline doesn't need secrets embedded in source code.


26. Azure DevOps + App Service

Suppose your application is deployed to:

Azure App Service documentation

Architecture:

Azure Repos
     |
     v
Azure Pipeline
     |
     v
Build
     |
     v
Test
     |
     v
Artifact
     |
     v
Azure App Service

27. Azure DevOps + Azure Functions

Exactly the same principle:

Git
 |
 v
Azure Pipeline
 |
 +-- Build
 +-- Test
 +-- Package
 |
 v
Azure Function

28. Azure DevOps + AKS

For containerized microservices:

Developer
    |
    v
Azure Repos
    |
    v
Azure Pipeline
    |
    +-- Build .NET
    +-- Test
    +-- Docker Build
    +-- Push Image
    |
    v
Azure Container Registry
    |
    v
AKS

This connects several Azure services you should know as a .NET Lead.


29. Docker + Azure DevOps

Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base

WORKDIR /app

EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build

WORKDIR /src

COPY . .

RUN dotnet restore

RUN dotnet publish \
    -c Release \
    -o /app/publish

FROM base AS final

WORKDIR /app

COPY --from=build /app/publish .

ENTRYPOINT ["dotnet", "OrderApi.dll"]

Pipeline:

Code
 ↓
Build
 ↓
Docker Image
 ↓
ACR
 ↓
AKS

30. Azure Container Registry

ACR stores container images.

Azure DevOps
      |
      v
docker build
      |
      v
Docker Image
      |
      v
Azure Container Registry
      |
      v
AKS

Example image:

mycompany.azurecr.io/order-api:1.0.0

31. Infrastructure as Code

A Lead should know that infrastructure shouldn't always be manually created in the Azure Portal.

Use:

Bicep
ARM templates
Terraform

Conceptually:

Infrastructure Code
       |
       v
Azure DevOps Pipeline
       |
       v
Azure Resources

Example:

Bicep
 ↓
App Service
 ↓
SQL
 ↓
Service Bus
 ↓
Key Vault
 ↓
Application Insights

This gives you repeatable environments.


32. Deployment Strategies

You should know these concepts.

Blue-Green

Production
    |
 +-- Blue
 |
 +-- Green

Deploy to Green and switch traffic when validated.


Canary

Users
 |
 +---- 95% → Version 1
 |
 +---- 5%  → Version 2

Monitor Version 2.

If healthy:

5%
 ↓
25%
 ↓
50%
 ↓
100%

Rolling

Gradually replace old instances with new ones.

These strategies are particularly relevant to App Service, AKS and modern deployment architectures.


33. CI/CD Security

Your pipeline should include:

Code
 ↓
Build
 ↓
Unit Tests
 ↓
Security Scan
 ↓
Dependency Scan
 ↓
Quality Checks
 ↓
Artifact
 ↓
Deployment

A Lead should think about:

  • Secret management

  • Least privilege

  • Service connections

  • Branch policies

  • Dependency vulnerabilities

  • Container image scanning

  • Approval controls

  • Audit logs


34. Service Connections

Azure DevOps needs permission to deploy to Azure.

Conceptually:

Azure DevOps
     |
     | Service Connection
     v
Azure Subscription
     |
     +---- App Service
     +---- Function
     +---- ACR
     +---- AKS

Use appropriate identity-based authentication and least privilege rather than broadly granting excessive permissions.


35. Self-Hosted vs Microsoft-Hosted Agents

Microsoft-hosted agent

Azure DevOps provides the machine.

Pipeline
   |
   v
Microsoft-hosted Agent

Advantages:

  • Easy setup

  • Clean environment

  • Microsoft-managed infrastructure

Self-hosted agent

Your organization manages the agent.

Pipeline
   |
   v
Company Agent

Useful when you need:

  • Private network access

  • Special software

  • Internal systems

  • Custom build environments


36. Azure DevOps + Private Network

Suppose your SQL server is private:

Azure DevOps
     |
     X
Public Internet

You may need an appropriate self-hosted agent/network architecture.

Azure DevOps
     |
     v
Self-hosted Agent
     |
     v
VNet
     |
     v
Private SQL

This is an excellent Lead-level scenario.


37. Azure DevOps + Application Insights

You can connect deployment and monitoring:

Azure DevOps
     |
     v
Deploy
     |
     v
App Service
     |
     v
Application Insights
     |
     v
Azure Monitor

Suppose deployment happens:

Version 1.2.0

Then Application Insights shows:

Error rate
   ↑
Latency
   ↑

The Lead can investigate whether the new release caused the regression.


38. Production Deployment Strategy

I would recommend:

Developer
   |
   v
Feature Branch
   |
   v
Pull Request
   |
   +-- Reviewer Approval
   +-- Build Validation
   +-- Unit Tests
   |
   v
main
   |
   v
CI Pipeline
   |
   v
Artifact
   |
   v
DEV
   |
   v
Automated Tests
   |
   v
QA
   |
   v
UAT
   |
   v
Production Approval
   |
   v
PROD
   |
   v
Application Insights

39. Important Lead-Level Principle

Build Once, Deploy Many

Don't do:

Build → DEV
Build → QA
Build → PROD

Instead:

Build
  |
  v
Artifact
  |
  +---- DEV
  |
  +---- QA
  |
  +---- PROD

The same artifact should progress through environments.

This reduces "works in QA but not in production" problems caused by different builds.


40. Another Important Principle — Shift Left

Testing shouldn't start only in production.

You want:

Developer
   ↓
Compile
   ↓
Unit Test
   ↓
Static Analysis
   ↓
Security Scan
   ↓
Integration Test
   ↓
Deploy

The earlier you detect a defect, the cheaper it is to fix.


41. Rollback

Suppose:

Version 2.0

is deployed and causes:

HTTP 500 ↑
Latency ↑
Exceptions ↑

A good pipeline should support rollback.

Conceptually:

Production
   |
   v
Version 2.0
   |
   X
Problem
   |
   v
Rollback
   |
   v
Version 1.9

But a mature deployment strategy also aims to make rollback safe with database migration compatibility and backward-compatible contracts.


42. Database Migration Problem

Suppose:

Application v2

requires:

NewColumn

You can't blindly rollback if the database migration has destroyed compatibility.

Use an approach such as:

Expand
   ↓
Deploy
   ↓
Migrate data
   ↓
Switch application
   ↓
Contract

This is an important Lead-level DevOps + architecture topic.


43. Azure DevOps vs GitHub Actions

You may be asked this.

Both support CI/CD.

Azure DevOps offers a broader suite:

Boards
Repos
Pipelines
Test Plans
Artifacts

GitHub combines source control, collaboration and Actions-based automation in a different platform model.

Lead answer:

"I don't choose solely based on tool popularity. I consider existing organizational tooling, source-control platform, enterprise governance, security, integrations, team expertise and deployment requirements."


44. Azure DevOps Interview Questions

Basic

  1. What is Azure DevOps?

  2. What is Azure Repos?

  3. What is Azure Boards?

  4. What is Azure Pipelines?

  5. What is Azure Artifacts?

  6. What is Azure Test Plans?

  7. What is Git?

  8. What is a Pull Request?

  9. What is CI?

  10. What is CD?


45. Intermediate Questions

  1. Explain a CI/CD pipeline.

  2. What is a build artifact?

  3. What is a pipeline agent?

  4. Microsoft-hosted vs self-hosted agent?

  5. What are environments?

  6. How do you configure DEV/QA/PROD?

  7. How do you handle secrets?

  8. What is a variable group?

  9. What are service connections?

  10. How do you implement approvals?

  11. What are branch policies?

  12. How do you implement rollback?

  13. How do you deploy .NET applications?

  14. How do you deploy Azure Functions?

  15. How do you deploy Docker containers to AKS?


46. Lead-Level Questions

Q26. Design CI/CD for a microservices application.

You should draw:

Git
 ↓
PR
 ↓
Build
 ↓
Test
 ↓
Security
 ↓
Artifact
 ↓
ACR
 ↓
AKS
 ↓
Application Insights

Q27. How would you secure the pipeline?

Answer:

"I would use least-privilege service connections, managed identities where supported, Key Vault for secrets, branch protection, PR approvals, secret scanning, dependency and container scanning, environment approvals, audit logging and separation of duties."


Q28. How would you implement zero-downtime deployment?

Discuss:

Blue/Green
Canary
Rolling deployment
Health checks
Backward-compatible DB changes
Monitoring
Rollback

Q29. How would you handle a failed production deployment?

Strong answer:

Detect
 ↓
Stop further rollout
 ↓
Check Application Insights
 ↓
Compare deployment version
 ↓
Determine impact
 ↓
Rollback / forward fix
 ↓
Verify health
 ↓
Root Cause Analysis
 ↓
Improve pipeline

Q30. How would you design a pipeline for 20 microservices?

Don't necessarily create one giant pipeline.

Consider:

             Shared Templates
                    |
       +------------+------------+
       |            |            |
       v            v            v
 Order Pipeline  Payment       Inventory
       |          Pipeline       Pipeline
       v            v            v
      ACR          ACR           ACR
       |            |             |
       v            v             v
      AKS          AKS           AKS

Use reusable YAML templates and standard pipeline conventions.


47. Real-Time .NET Lead Example

Let's put everything together.

Your company has:

Angular
ASP.NET Core
Azure SQL
Service Bus
Azure Functions
AKS
Key Vault
Application Insights

The delivery architecture:

                      Developer
                          |
                          v
                    Azure Repos
                          |
                          v
                    Pull Request
                          |
                 +--------+--------+
                 |                 |
                 v                 v
              Review         Build Validation
                                   |
                                   v
                              Azure Pipeline
                                   |
               +-------------------+-------------------+
               |                   |                   |
               v                   v                   v
             Build              Unit Test          Security
               |                   |                   |
               +-------------------+-------------------+
                                   |
                                   v
                              Docker Build
                                   |
                                   v
                         Azure Container Registry
                                   |
                                   v
                                  AKS
                                   |
                                   v
                          Application Insights
                                   |
                                   v
                            Azure Monitor

This is a very strong architecture to explain in a Lead interview.


48. What Would I Say in the Interview?

If asked:

"Explain how you have used Azure DevOps in your project."

You can answer:

"We used Azure Repos for Git-based source control and Azure Boards for Agile work management. Developers worked on feature branches and created pull requests with mandatory reviews and build validation. Azure Pipelines implemented CI/CD. The CI stage restored dependencies, built the .NET solution, executed unit tests and security/quality checks, and published an immutable artifact. Deployment stages promoted the same artifact through DEV, QA, UAT and Production with environment-specific configuration and approvals. Secrets were managed through Key Vault, and production deployments were monitored through Application Insights and Azure Monitor. For containerized services, the pipeline built Docker images, pushed them to Azure Container Registry and deployed them to AKS."

That's a strong .NET Lead-level answer.


49. One Diagram to Memorize

For your interview, remember this:

                         AZURE DEVOPS
                              |
       +----------------------+----------------------+
       |                      |                      |
       v                      v                      v
    BOARDS                  REPOS                PIPELINES
       |                      |                      |
    Stories                 Git                 Build
    Tasks                   PR                  Test
    Bugs                    Review              Package
       |                      |                  Deploy
       +----------------------+----------------------+
                              |
                              v
                           Artifact
                              |
                +-------------+-------------+
                |             |             |
                v             v             v
               DEV           QA            PROD
                                             |
                                             v
                                    Application Insights
                                             |
                                             v
                                       Azure Monitor

The 10 things I recommend mastering for your Lead interview

  1. Git + Branching Strategy

  2. Pull Requests + Branch Policies

  3. CI/CD

  4. YAML Pipelines

  5. Build Artifacts

  6. Multi-stage deployment

  7. Environment approvals

  8. Key Vault + Secret Management

  9. Docker + ACR + AKS deployment

  10. Application Insights + Azure Monitor integration


Azure Monitor & Application Insights

Azure Monitor documentation

Application Insights documentation

1. First understand the difference

The easiest way to remember:

Application Insights = Monitor your application.
Azure Monitor = Monitor your overall Azure environment.

Think of it like this:

                    Azure Monitor
                         |
       +-----------------+------------------+
       |                 |                  |
       v                 v                  v
 Application         Infrastructure      Azure Resources
  Insights              Metrics             Logs
       |
       +--- Requests
       +--- Exceptions
       +--- Dependencies
       +--- Traces
       +--- Availability

Application Insights is an Azure Monitor feature for application performance monitoring (APM). It can collect telemetry such as requests, dependencies, exceptions, traces and availability information.


2. Real-Time Project

Let's imagine you are a .NET Lead working on an e-commerce application.

Architecture:

                         Angular
                            |
                            v
                    Azure API Management
                            |
                            v
                    ASP.NET Core API
                            |
             +--------------+--------------+
             |                             |
             v                             v
         Azure SQL                    Azure Service Bus
                                           |
                                           v
                                    Azure Function
                                           |
                               +-----------+-----------+
                               |                       |
                               v                       v
                           Payment                 Notification
                           Service                   Service

Now your manager says:

"Production users are complaining that the Order API is slow."

You need to answer:

Where is the problem?

Is it:

Angular?
API?
SQL?
Service Bus?
Payment API?
Azure Function?
Network?

This is where Application Insights + Azure Monitor become extremely useful.


3. What does Application Insights collect?

For an ASP.NET Core application, you can monitor:

Requests

POST /api/orders
GET /api/products
GET /api/customers/100

Dependencies

SQL
HTTP API
Service Bus
Redis
Storage

Exceptions

SqlException
HttpRequestException
NullReferenceException
TimeoutException

Traces

Your application logs:

_logger.LogInformation(
    "Order {OrderId} created",
    orderId);

Availability

You can monitor whether your application/API is reachable and responding correctly.


4. Real-Time Problem

Suppose your customer reports:

"Creating an order takes 10 seconds."

You open Application Insights.

You see:

POST /api/orders

Duration: 10.4 seconds

Now you need to find why.

Application Insights can show the request's dependencies.

You discover:

Order API
    |
    +---- SQL: 0.5 sec
    |
    +---- Payment API: 8.7 sec
    |
    +---- Service Bus: 0.3 sec

Immediately:

Payment API = 8.7 seconds

You have identified the bottleneck.

That's the real value of Application Insights.


5. Application Insights Architecture

Conceptually:

ASP.NET Core API
      |
      | Telemetry
      v
Application Insights
      |
      v
Azure Monitor
      |
 +----+-----+----------+
 |          |          |
 v          v          v
Logs      Metrics    Alerts

6. Step 1 — Create Application Insights

In Azure Portal:

Azure Portal
     ↓
Create a resource
     ↓
Search "Application Insights"
     ↓
Create

You'll generally associate it with the appropriate Azure resource/workload.


7. Step 2 — Add Application Insights to .NET

For an ASP.NET Core application, add the Application Insights SDK.

For example:

dotnet add package Microsoft.ApplicationInsights.AspNetCore

Then in Program.cs:

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddApplicationInsightsTelemetry();

builder.Services.AddControllers();

var app = builder.Build();

app.MapControllers();

app.Run();

Your application can then send telemetry to Application Insights.


8. Connection Configuration

Application Insights uses a connection string.

For example:

{
  "ApplicationInsights": {
    "ConnectionString": "YOUR_CONNECTION_STRING"
  }
}

In production, don't commit secrets or sensitive configuration into Git.

Use appropriate Azure configuration/security mechanisms such as managed identity, Key Vault and environment configuration.


9. Add Logging

Suppose we have:

[HttpPost]
public async Task<IActionResult> CreateOrder(
    CreateOrderRequest request)
{
    _logger.LogInformation(
        "Creating order for customer {CustomerId}",
        request.CustomerId);

    // Business logic

    return Ok();
}

Application Insights can capture this telemetry.


10. Structured Logging

Avoid:

_logger.LogInformation(
    "Customer 1001 created order 5001");

Prefer:

_logger.LogInformation(
    "Customer {CustomerId} created Order {OrderId}",
    customerId,
    orderId);

Why?

Because structured properties make logs easier to search, filter and correlate.


11. Real-Time Example — Order API

Let's build a simple service.

POST /api/orders

Controller:

[ApiController]
[Route("api/orders")]
public class OrdersController : ControllerBase
{
    private readonly ILogger<OrdersController> _logger;
    private readonly IOrderService _orderService;

    public OrdersController(
        ILogger<OrdersController> logger,
        IOrderService orderService)
    {
        _logger = logger;
        _orderService = orderService;
    }

    [HttpPost]
    public async Task<IActionResult> CreateOrder(
        CreateOrderRequest request)
    {
        _logger.LogInformation(
            "Creating order for Customer {CustomerId}",
            request.CustomerId);

        var result =
            await _orderService.CreateAsync(request);

        _logger.LogInformation(
            "Order {OrderId} created successfully",
            result.OrderId);

        return Ok(result);
    }
}

12. Add Exception Logging

try
{
    var result =
        await _orderService.CreateAsync(request);

    return Ok(result);
}
catch (Exception ex)
{
    _logger.LogError(
        ex,
        "Error creating order for Customer {CustomerId}",
        request.CustomerId);

    throw;
}

Application Insights can then help you find:

Exceptions
    |
    +--- Exception Type
    +--- Message
    +--- Stack Trace
    +--- Request
    +--- Timestamp

13. Application Insights — Failures

Suppose production shows:

Failures
-----------------------------
Exceptions       1,243
Failed Requests   850

You click Failures.

You discover:

SqlException
Timeout expired

Now you investigate the database dependency.


14. Application Insights — Performance

Suppose:

Requests
-------------------------------
GET /api/products     100ms
GET /api/customers    150ms
POST /api/orders      8.7 sec

You immediately know:

POST /api/orders

needs investigation.


15. Dependency Tracking

This is one of the most useful features.

Your API:

POST /api/orders

calls:

Azure SQL
Payment API
Service Bus

Application Insights can help show the dependency calls and their duration.

Conceptually:

POST /api/orders
       |
       +---- SQL
       |     300 ms
       |
       +---- Payment API
       |     8,000 ms
       |
       +---- Service Bus
             100 ms

Now your troubleshooting becomes much faster.


16. Distributed Tracing

This becomes very important in microservices.

Imagine:

Angular
   |
   v
API Management
   |
   v
Order API
   |
   v
Service Bus
   |
   v
Payment Function
   |
   v
Payment API
   |
   v
Azure SQL

The user says:

"Order 5001 failed."

You need to trace the entire operation.

This is where correlation IDs and distributed tracing become extremely valuable.


17. Correlation ID

Suppose we create:

CorrelationId = ABC-123

Then:

Order API
    |
    | ABC-123
    v
Service Bus
    |
    | ABC-123
    v
Payment Function
    |
    | ABC-123
    v
Payment API

You can search logs/telemetry around that operation.


18. Custom Telemetry

You can also send custom telemetry using TelemetryClient.

For example:

using Microsoft.ApplicationInsights;

public class PaymentService
{
    private readonly TelemetryClient _telemetry;

    public PaymentService(
        TelemetryClient telemetry)
    {
        _telemetry = telemetry;
    }

    public async Task ProcessPaymentAsync(
        int orderId,
        decimal amount)
    {
        _telemetry.TrackEvent(
            "PaymentStarted",
            new Dictionary<string, string>
            {
                ["OrderId"] = orderId.ToString()
            });

        // Payment processing

        _telemetry.TrackMetric(
            "PaymentAmount",
            (double)amount);

        await Task.CompletedTask;
    }
}

19. Custom Events

For business monitoring, custom events can be useful.

Example:

OrderCreated
PaymentCompleted
PaymentFailed
InvoiceGenerated

Then you can investigate business activity in addition to technical telemetry.


20. Azure Monitor

Now let's move one level higher.

Application Insights focuses heavily on application telemetry.

Azure Monitor provides broader monitoring capabilities across Azure resources and applications.

Think:

                    Azure Monitor
                         |
        +----------------+----------------+
        |                |                |
        v                v                v
    Application       Platform         Infrastructure
     Insights          Metrics            Logs
        |
        v
    Application

Examples of Azure resources you might monitor:

App Service
Azure SQL
Service Bus
Storage
Functions
AKS
Virtual Machines

21. Azure Monitor Metrics

Suppose Azure SQL is slow.

You could examine metrics related to:

CPU
Storage
Connections
Database performance

For Service Bus:

Messages
Active messages
Dead-lettered messages
Incoming/outgoing operations

For App Service:

CPU
Memory
Requests
HTTP errors
Response time

The exact available metrics depend on the Azure resource.


22. Logs vs Metrics

Very important interview question.

Metrics

Numerical measurements.

Example:

CPU = 78%
Memory = 65%
Requests = 10,000
Response Time = 1.5 sec

Good for:

Dashboards
Alerts
Trend analysis

Logs

Detailed records.

Example:

Order 1001 failed because SQL timeout occurred.

Good for:

Troubleshooting
Debugging
Detailed investigation

23. Azure Monitor Logs and KQL

One of the most important skills for Azure interviews is Kusto Query Language (KQL).

You can query telemetry in Azure Monitor Logs/Application Insights.

For example, a request query might look like:

requests
| where timestamp > ago(1h)
| summarize
    Count = count(),
    AvgDuration = avg(duration)
    by name
| order by AvgDuration desc

This answers:

"Which API endpoints have the highest average duration during the last hour?"


24. Find Failed Requests

requests
| where success == false
| project
    timestamp,
    name,
    resultCode,
    duration
| order by timestamp desc

This gives you failed requests and their details.


25. Find Exceptions

exceptions
| where timestamp > ago(1h)
| project
    timestamp,
    type,
    outerMessage
| order by timestamp desc

You can investigate what exceptions are happening in production.


26. Find Slow APIs

requests
| where timestamp > ago(1h)
| where duration > 2000
| project
    timestamp,
    name,
    duration,
    resultCode
| order by duration desc

This finds requests taking more than 2 seconds.


27. Find SQL Dependency Problems

Conceptually, you can query dependency telemetry:

dependencies
| where timestamp > ago(1h)
| where duration > 1000
| project
    timestamp,
    name,
    target,
    duration,
    success
| order by duration desc

You might discover:

SQL Query
Duration: 4.2 sec

Now you investigate SQL.


28. Application Map

One of the most useful visual concepts is the Application Map.

Imagine:

                  Order API
                      |
        +-------------+-------------+
        |             |             |
        v             v             v
      SQL        Service Bus     Payment API
                      |
                      v
                Azure Function

This helps you understand:

  • Dependencies

  • Failures

  • Performance

  • Service relationships

For a microservices environment, this is extremely valuable.


29. Real-Time Production Problem

Let's walk through a real incident.

User complaint

"Order creation is taking 15 seconds."

You start with:

Application Insights
        ↓
Performance

You discover:

POST /api/orders
Duration = 15 seconds

Then inspect dependencies:

SQL              = 300 ms
Service Bus      = 200 ms
Payment API      = 14.2 sec

Problem identified:

Payment API

Then you inspect the Payment API.

You find:

Payment API
   |
   v
SQL Query
   |
   v
Slow query = 13 seconds

Now you move to:

Azure SQL

You investigate:

  • Query execution plan

  • Indexes

  • Blocking

  • CPU

  • Database resource usage

This is how monitoring helps you move from:

"Application is slow"

to:

"Payment API's SQL dependency is causing the latency."


30. Alerts

Monitoring without alerts isn't enough.

Imagine:

API failure rate > 5%

You can configure an alert.

Conceptually:

API
 |
 v
Application Insights
 |
 v
Failure Rate > 5%
 |
 v
Azure Monitor Alert
 |
 +---- Email
 +---- Teams/notification integration
 +---- Incident management

Similarly:

SQL CPU > threshold
Service Bus DLQ > threshold
API latency > threshold
Function failures > threshold

can be monitored with appropriate alert rules.


31. Service Bus Monitoring Example

Your architecture:

Order API
    |
    v
Service Bus
    |
    v
Order Function

Suddenly users report:

"Orders aren't getting processed."

You open Service Bus monitoring.

You discover:

Active Messages = 50,000
Dead Letter = 5,000

This tells you the consumer is falling behind or failing.

Then Application Insights shows:

Order Function
    |
    v
SQL TimeoutException

Now you've connected:

Service Bus backlog
       ↓
Function failures
       ↓
SQL timeout

This is the kind of troubleshooting a Lead should be able to explain.


32. Azure Monitor + Application Insights + Service Bus

Complete monitoring picture:

                         Azure Monitor
                              |
             +----------------+----------------+
             |                                 |
             v                                 v
     Application Insights                Azure Metrics
             |
     +-------+-------+
     |       |       |
     v       v       v
 Requests  Errors  Dependencies
     |
     +---- API
     +---- SQL
     +---- Service Bus
     +---- External APIs

33. Production Logging Strategy

Don't just write:

Console.WriteLine("Something happened");

Prefer:

_logger.LogInformation(
    "Order {OrderId} submitted by Customer {CustomerId}",
    orderId,
    customerId);

And:

_logger.LogError(
    exception,
    "Failed to process Order {OrderId}",
    orderId);

This gives structured telemetry that is much easier to query.


34. What Should You NOT Log?

Never casually log:

Passwords
Connection strings
Access tokens
API keys
Credit card information
Sensitive personal information

For example, don't do:

_logger.LogInformation(
    "Payment token = {Token}",
    token);

That's a security problem.


35. Health Checks vs Application Insights

Don't confuse them.

Health Check

Answers:

"Is my application/dependency healthy right now?"

Example:

/api/health

Application Insights

Answers:

"What has my application been doing? What failed? What is slow? What dependencies are causing problems?"

They complement each other.


36. Application Insights vs Azure Monitor — Interview Answer

If interviewer asks:

"What's the difference between Azure Monitor and Application Insights?"

Answer:

"Application Insights is an application performance monitoring capability within Azure Monitor. It focuses on application telemetry such as requests, dependencies, exceptions, traces and availability. Azure Monitor provides the broader monitoring platform for Azure resources, infrastructure, metrics, logs, alerts and application telemetry."

That's a strong answer.


37. Lead-Level Architecture

For a production system, I'd propose:

                         Users
                           |
                           v
                    API Management
                           |
                           v
                     App Service
                           |
          +----------------+----------------+
          |                                 |
          v                                 v
      Azure SQL                       Service Bus
                                            |
                                            v
                                       Azure Function
                                            |
                                            v
                                     External Payment
                                            |
                                            v
                                      Notification


          ALL COMPONENTS
                 |
                 v
          Azure Monitor
                 |
        +--------+--------+
        |                 |
        v                 v
 Application          Resource
  Insights             Metrics
        |
 +------+--------+
 |      |        |
 v      v        v
Logs  Traces  Exceptions
        |
        v
      KQL
        |
        v
     Alerts

38. Lead Interview Scenario

Interviewer:

"Production API is slow. How would you troubleshoot it?"

Don't say:

"I'll check the code."

Give a structured answer.

Step 1 — Application Insights

Check:

Request duration
Failure rate
Exceptions
Dependencies

Step 2 — Identify bottleneck

Example:

API = 10 seconds

SQL = 1 sec
Service Bus = 100 ms
Payment API = 8.5 sec

Step 3 — Drill down

Investigate Payment API.

Step 4 — Check Azure Monitor

Look at:

CPU
Memory
Network
Database metrics
Service Bus backlog

Step 5 — KQL

Query slow requests/dependencies.

Step 6 — Correlation

Follow the same operation across services using distributed tracing/correlation.

Step 7 — Fix

Potential causes:

Slow SQL query
Missing index
External API latency
Connection pool exhaustion
Thread starvation
High CPU
Service Bus backlog
Network issue

Step 8 — Prevent recurrence

Add:

Alert
Dashboard
Performance baseline
Capacity planning

That demonstrates Lead-level troubleshooting rather than simply knowing where the Azure Portal menus are.


39. Top KQL Queries to Remember

Failed requests

requests
| where success == false
| project timestamp, name, resultCode, duration

Slow requests

requests
| where duration > 2000
| project timestamp, name, duration
| order by duration desc

Exceptions

exceptions
| project timestamp, type, outerMessage
| order by timestamp desc

Request count

requests
| summarize count() by bin(timestamp, 5m)

Average response time

requests
| summarize avg(duration) by name
| order by avg_duration desc

Dependency failures

dependencies
| where success == false
| project timestamp, name, target, duration

40. Interview Questions

Basic

  1. What is Azure Monitor?

  2. What is Application Insights?

  3. What is the difference between them?

  4. What is telemetry?

  5. What is distributed tracing?

  6. What are dependencies?

  7. What is Application Map?

  8. What are metrics?

  9. What are logs?

  10. What are alerts?

Intermediate

  1. How do you monitor an ASP.NET Core API?

  2. How do you capture exceptions?

  3. How do you monitor SQL dependencies?

  4. How do you monitor Service Bus?

  5. How do you find slow APIs?

  6. What is KQL?

  7. How do you configure alerts?

  8. How do you track external API calls?

  9. How do you monitor Azure Functions?

  10. How do you troubleshoot production failures?

Lead-level

  1. How would you monitor a microservices architecture?

  2. How do you trace a request across multiple services?

  3. How do you troubleshoot an API taking 10 seconds?

  4. How do you identify whether SQL or an external API is causing latency?

  5. How do you design monitoring for a production system?

  6. What metrics would you monitor for Service Bus?

  7. How would you monitor Azure SQL?

  8. How do you design alerting without creating alert fatigue?

  9. What should and shouldn't be logged?

  10. How do you implement observability across microservices?


41. Three Words to Remember

For a Lead interview, remember:

Logs

What happened?

Metrics

How much/how often?

Traces

Where did the request travel and where did it spend time?

Together:

                 Observability
                      |
          +-----------+-----------+
          |           |           |
          v           v           v
         Logs       Metrics      Traces
          |           |           |
          v           v           v
       Details     Numbers     Journey

42. Final Real-Time Example

Imagine this production flow:

Customer
   |
   v
Angular
   |
   v
API Management
   |
   v
Order API
   |
   +-------> Azure SQL
   |
   +-------> Service Bus
                 |
                 v
            Azure Function
                 |
                 v
            Payment API

Customer says:

"My order is taking 12 seconds."

You don't randomly check everything.

You follow:

Application Insights
       ↓
Request
       ↓
POST /api/orders
       ↓
12 seconds
       ↓
Dependencies
       ↓
SQL = 300ms
Service Bus = 100ms
Payment API = 11.2 sec
       ↓
Payment API
       ↓
Dependency
       ↓
SQL Query = 10.8 sec
       ↓
Azure Monitor
       ↓
SQL resource metrics
       ↓
Find bottleneck
       ↓
Fix SQL/index/query
       ↓
Create alert


Don't Copy

Protected by Copyscape Online Plagiarism Checker