.NET Core Version
Current .NET versions:
.NET 6 – LTS (Support ended)
.NET 8 – Current LTS (Most companies use this)
.NET 9 – Standard Term Support (STS)
Answer
I have primarily worked on .NET Core 6 and .NET 8 for developing REST APIs and Microservices. Most production applications are currently on .NET 8 because it is an LTS version.
What is your approach in CQRS Pattern?
CQRS (Command Query Responsibility Segregation) separates read and write operations.
Command Side
Insert
Update
Delete
Query Side
Read operations only
Workflow
Client
|
Command API
|
Command Handler
|
Database
Client
|
Query API
|
Query Handler
|
Read Database
Advantages
Better scalability
Better performance
Independent optimization
Easy maintenance
How do Microservices communicate?
Two ways:
1. Synchronous
REST API
gRPC
Used when immediate response is required.
Example
Order Service
|
REST API
|
Inventory Service
2. Asynchronous
Using
RabbitMQ
Kafka
Azure Service Bus
AWS SQS
Used for
Email
Notifications
Payment
Order processing
No direct dependency.
How do you populate data from two tables using Microservices?
Never directly join another service's database.
Correct approaches:
Option 1 (Most common)
Order Service calls Customer Service API.
Order Service
|
Customer API
|
Customer Details
Merge the response.
Option 2
Use API Gateway or Aggregator Service.
Client
|
Aggregator Service
/ \
Order Customer
Option 3
CQRS Read Model
Combine data using events.
Request Flow in Microservices
Client
API Gateway
Authentication
Order Service
Business Logic
Database
Response
If another service is required
Order Service
Inventory Service
Payment Service
Notification Service
What is an Abstract Class?
An abstract class cannot be instantiated.
It contains
Abstract methods
Normal methods
Constructors
Fields
Example
abstract class Animal
{
public abstract void Sound();
public void Eat()
{
Console.WriteLine("Eating");
}
}
Used when multiple classes share common functionality.
If two tables need updating in Microservices?
If both tables belong to same service
Use
TransactionScope
or
Begin Transaction
Commit
Rollback
If different microservices
Don't use distributed transactions.
Use
Saga Pattern
Event-driven architecture
API Gateway Techniques
Popular gateways
YARP (.NET)
Ocelot
Azure API Management
AWS API Gateway
Kong
Responsibilities
Authentication
Authorization
Routing
Load balancing
Rate limiting
Logging
SSL termination
Caching
Authentication in Microservices
Usually JWT with OAuth2/OpenID Connect.
Flow
User Login
Identity Provider
JWT Generated
Client stores JWT
Each request sends JWT
API Gateway validates
Microservice validates
How to Configure JWT?
Install
Microsoft.AspNetCore.Authentication.JwtBearer
Program.cs
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer=true,
ValidateAudience=true,
ValidateLifetime=true,
ValidateIssuerSigningKey=true
};
});
Four Microservices - User communicates with only one service?
User never calls all services.
Flow
Client
API Gateway
Order Service
Inventory Service
Payment Service
Notification Service
Gateway routes requests.
JWT Lifecycle
Login
Generate JWT
Return Token
Client stores Token
Every Request
Validate JWT
Expired
Refresh Token
New JWT
Main Purpose of Terraform
Infrastructure as Code (IaC).
Automates
EC2
S3
RDS
VPC
IAM
Kubernetes
Azure Resources
Benefits
Version Control
Automation
Repeatability
Easy rollback
CI/CD Pipeline Issues
Common challenges
Build failures
Dependency conflicts
Deployment failures
Wrong environment variables
Secret management
Docker image issues
Rollback
Long build time
Test failures
How do you maintain logs?
Centralized logging.
Popular tools
Serilog
NLog
ELK Stack
Splunk
Grafana Loki
Azure Application Insights
AWS CloudWatch
Always include
Correlation ID
User ID
Request ID
Exception details
What is RDS?
Amazon RDS
Managed relational database.
Supports
SQL Server
MySQL
PostgreSQL
MariaDB
Oracle
Features
Backup
Monitoring
High Availability
Scaling
Read Replica vs Write Replica
Primary
Read
Write
Read Replica
Read only
Purpose
Reporting
Analytics
High read traffic
Disaster Recovery in Same AZ?
Not recommended.
AZ failure impacts everything.
Use
Multi-AZ
Cross-region replication
Automated backups
Availability Zone vs Region
| Region | Availability Zone |
|---|---|
| Geographic location | One or more data centers |
| Example: Mumbai | ap-south-1a |
| Multiple AZs | Independent power/network |
How does AZ work?
Application deployed across
AZ-1
AZ-2
AZ-3
If one AZ fails
Traffic moves automatically.
Authentication vs Authorization
Authentication
Who are you?
Example
Login
Authorization
What can you access?
Example
Admin
Employee
Manager
Concurrency vs Parallelism
Concurrency
Multiple tasks make progress.
Parallelism
Multiple tasks execute simultaneously.
Unit Testing
Tests individual methods.
Popular frameworks
xUnit
NUnit
MSTest
Mocking
Moq
CQRS Workflow
Client
Command API
Command Handler
Database
Publish Event
Update Read Model
Query API
Read Database
Response
Design Patterns in Microservices
CQRS
Saga
Circuit Breaker
API Gateway
Repository
Dependency Injection
Factory
Observer
Retry Pattern
Bulkhead
Outbox Pattern
Snapshot (AWS)
Snapshot
Point-in-time backup of
EBS
RDS
Used for
Disaster Recovery
Restore
Migration
Why React?
Advantages
Component-based
Virtual DOM
Fast rendering
Reusable components
Large ecosystem
Easy integration with APIs
.NET Framework vs .NET Core
| .NET Framework | .NET |
|---|---|
| Windows only | Cross-platform |
| Slower | Faster |
| IIS dependent | Self-hosted/Kestrel |
| Older | Modern |
| Less cloud friendly | Cloud-native |
| Limited containers | Docker/Kubernetes support |
Middleware
Middleware processes every HTTP request.
Pipeline
Request
Logging
Authentication
Authorization
Exception
Controller
Response
If Middleware fails?
If exception isn't handled
Request stops.
Returns
500 Internal Server Error
Use
app.UseExceptionHandler();
Global exception middleware prevents application crash.
JWT Token
Contains
Header
Payload
Signature
Stateless authentication.
Expiry Time
Usually
15 minutes
30 minutes
1 hour
Configured using
expires: DateTime.UtcNow.AddMinutes(30)
Refresh Token Purpose
Used to obtain a new JWT without requiring the user to log in again.
Benefits
Better security
Improved user experience
Delegate in C#
A delegate is a type-safe function pointer.
Example
delegate void Notify();
Notify n = ShowMessage;
Multicast Delegate
Can invoke multiple methods.
notify += Email;
notify += SMS;
notify();
Both methods execute.
Unique Elements with Collections
Use
HashSet<int>
Automatically removes duplicates.
Binary Search vs Linear Search
| Binary Search | Linear Search |
|---|---|
| Sorted data required | No sorting needed |
| O(log n) | O(n) |
| Faster | Slower |
Which Data Structures do you use?
Dictionary → Fast lookup
List → Sequential data
HashSet → Unique values
Queue → FIFO
Stack → LIFO
ConcurrentDictionary → Multithreading
Code First Approach
Write C# classes first.
Entity Framework creates database.
Commands
Add-Migration
Update-Database
JWT NuGet Package
Microsoft.AspNetCore.Authentication.JwtBearer
Also commonly used:
System.IdentityModel.Tokens.Jwt
Protect API From
JWT Authentication
OAuth2
HTTPS
Rate Limiting
API Gateway
IP Filtering
CORS
Input Validation
WAF
Prevent API from DDoS
AWS Shield
AWS WAF
Azure Front Door
Azure DDoS Protection
API Gateway Rate Limiting
CDN
Load Balancer
Auto Scaling
Indexes
Improve query performance.
Types
Clustered
Non-clustered
Composite
Filtered
Unique
How many Clustered Indexes?
Clustered
Only 1 per table.
Non-clustered
Up to 999 per table (SQL Server).
SQL Query Performance
Techniques
Proper indexes
Avoid
SELECT *Use execution plans
Optimize joins
Use stored procedures where appropriate
Partition large tables
Keep statistics updated
Avoid unnecessary cursors
Circuit Breaker
Prevents repeated calls to a failing service.
States
Closed
Open
Half-Open
In .NET, commonly implemented using Polly.
S3 Bucket (AWS)
Amazon S3 is an object storage service.
Uses
File storage
Image storage
Document storage
Static website hosting
Backups
Log storage
Features
High durability (11 9's)
Versioning
Lifecycle policies
Encryption
Cross-region replication
These are the most frequently asked interview topics for a Senior .NET Developer (10+ years). Below are concise yet interview-ready explanations.
1. Azure Functions
What is Azure Functions?
Azure Functions is a serverless compute service that lets you execute code in response to events without managing servers.
Key Features
Serverless
Auto Scaling
Pay only for execution
Event-driven
Supports C#, Java, Python, Node.js
Types of Triggers
| Trigger | Use Case |
|---|---|
| HTTP Trigger | REST APIs |
| Timer Trigger | Scheduled jobs |
| Queue Trigger | Process Azure Queue messages |
| Service Bus Trigger | Process messages from Azure Service Bus |
| Blob Trigger | Process uploaded files |
| Event Hub Trigger | Process streaming data |
| Event Grid Trigger | React to Azure events |
| Cosmos DB Trigger | React to database changes |
Bindings
Bindings reduce boilerplate code.
Input Binding
Reads data automatically.
[BlobInput("images/{name}")]
Output Binding
Writes data automatically.
[BlobOutput("output/{name}")]
Hosting Plans
Consumption Plan
Flex Consumption Plan
Premium Plan
Dedicated (App Service) Plan
Interview Question
Q: Why Azure Functions?
Answer:
No server management
Auto scaling
Cost-effective
Event-driven
Fast development
2. Application Insights
Application Insights is Azure Monitor's APM (Application Performance Monitoring) solution.
It monitors
Requests
Exceptions
Dependencies
Performance
Availability
User behavior
What does it capture?
API execution time
SQL execution
HTTP calls
Exceptions
Memory usage
CPU
Availability tests
Sample Logging
_logger.LogInformation("Order Created");
_logger.LogWarning("Retrying");
_logger.LogError(ex, "Payment Failed");
Custom Events
telemetryClient.TrackEvent("PaymentSuccess");
Interview Question
How do you monitor production applications?
Answer:
Application Insights
Azure Monitor
Alerts
Dashboards
Live Metrics
3. Logging
Logging records application activity for diagnostics and monitoring.
Log Levels
| Level | Purpose |
|---|---|
| Trace | Detailed diagnostics |
| Debug | Development |
| Information | Normal operations |
| Warning | Unexpected but recoverable |
| Error | Failed operations |
| Critical | Application crash |
Best Practices
Structured logging
Correlation IDs
Avoid logging secrets
Log exceptions with stack trace
Centralize logs
Example
_logger.LogInformation("Order {OrderId} Created", orderId);
4. Exception Handling
Purpose
Handle runtime errors gracefully.
Types
Try Catch
Finally
Global Exception Middleware
Exception Filters
Example
try
{
}
catch(Exception ex)
{
_logger.LogError(ex,"Error");
}
Global Exception Middleware
Client
↓
Middleware
↓
Exception
↓
Log
↓
Return JSON Error
Benefits
Centralized handling
Consistent responses
Logging
Better security
5. Saga Pattern
Purpose
Manages distributed transactions in Microservices.
Instead of
One Transaction
Use
Local Transaction
↓
Next Service
↓
Next Service
↓
Compensating Transaction
Types
Choreography
Orchestration
Compensation Example
Payment Success
↓
Inventory Reserved
↓
Shipping Failed
↓
Refund Payment
↓
Release Inventory
↓
Cancel Order
6. .NET Core Middleware
Middleware is software that handles HTTP requests and responses in the ASP.NET Core pipeline.
Pipeline
Request
↓
Authentication
↓
Authorization
↓
Routing
↓
Custom Middleware
↓
Controller
↓
Response
Common Middleware
Authentication
Authorization
Routing
CORS
Static Files
Exception Handling
HTTPS Redirection
Swagger
Custom Middleware
public async Task Invoke(HttpContext context)
{
await _next(context);
}
Middleware Order
Exception
↓
HTTPS
↓
Static Files
↓
Routing
↓
Authentication
↓
Authorization
↓
Endpoints
7. C# Advanced Topics
Delegates
Stores method references.
delegate void Notify();
Events
Publisher/Subscriber pattern.
Lambda Expressions
x => x.Id
LINQ
Query collections.
employees.Where(x=>x.Salary>50000);
Async Await
Improves scalability.
await service.GetDataAsync();
Task Parallel Library
Parallel execution.
Reflection
Inspect types at runtime.
Generics
Reusable type-safe classes.
Extension Methods
Add methods without modifying classes.
Records
Immutable reference types.
Pattern Matching
switch
is
when
Nullable Reference Types
Avoid NullReferenceException.
Dependency Injection
Constructor Injection
Memory Management
Stack
Heap
Garbage Collection
IDisposable
Releases unmanaged resources.
Span
High-performance memory access.
Yield
Lazy iteration.
8. OOP
Four Pillars
Encapsulation
Hide internal data.
Abstraction
Show only required functionality.
Inheritance
Reuse code.
Polymorphism
Same method, different behavior.
Compile Time
Method Overloading
Runtime
Method Overriding
9. SOLID Principles
S
Single Responsibility Principle
One class → One responsibility
O
Open Closed Principle
Open for Extension
Closed for Modification
L
Liskov Substitution Principle
Derived class should replace base class without changing behavior.
I
Interface Segregation Principle
Small interfaces are better than large ones.
D
Dependency Inversion Principle
Depend on abstractions, not concrete implementations.
Common Interview Questions
| Question | Expected Answer |
|---|---|
| Difference between Azure Function and Web API | Azure Functions are event-driven and serverless; Web APIs are continuously hosted and ideal for long-running REST services. |
| What is Middleware? | Software that processes HTTP requests and responses in the ASP.NET Core pipeline. |
| Explain Application Insights. | Azure service for monitoring requests, dependencies, exceptions, performance, and availability. |
| How do you handle exceptions globally? | Use custom exception-handling middleware to log errors and return standardized error responses. |
| Difference between Logging and Application Insights? | Logging records application events, while Application Insights collects logs plus telemetry such as requests, dependencies, performance metrics, and exceptions. |
| Explain Saga Pattern. | Coordinates distributed transactions across microservices using local transactions and compensating actions instead of a single distributed transaction. |
| Explain SOLID. | Five object-oriented design principles that improve maintainability, extensibility, and testability. |
| What are advanced C# features? | Delegates, events, LINQ, async/await, generics, reflection, extension methods, records, pattern matching, nullable reference types, Span, and dependency injection. |
1. How did you implement Global Exception Handling using Custom Middleware?
Interview Answer
"In my ASP.NET Core applications, I implemented a custom Global Exception Handling Middleware to centralize exception handling. Instead of writing try-catch blocks in every controller or service, all unhandled exceptions are captured by the middleware. It logs the exception details using ILogger and Application Insights, maps different exception types to appropriate HTTP status codes, and returns a standardized JSON error response. This ensures consistent error handling, better logging, and avoids exposing sensitive exception details to clients."
"In my ASP.NET Core applications, I implemented a custom Global Exception Handling Middleware to centralize exception handling. Instead of writing try-catch blocks in every controller or service, all unhandled exceptions are captured by the middleware. It logs the exception details using ILogger and Application Insights, maps different exception types to appropriate HTTP status codes, and returns a standardized JSON error response. This ensures consistent error handling, better logging, and avoids exposing sensitive exception details to clients."
Request Flow
Client Request
│
▼
Middleware Pipeline
│
▼
Custom Exception Middleware
│
▼
Controller
│
▼
Service
│
▼
Database
Client Request
│
▼
Middleware Pipeline
│
▼
Custom Exception Middleware
│
▼
Controller
│
▼
Service
│
▼
Database
If an exception occurs:
Exception
│
▼
Middleware catches Exception
│
├── Log to Application Insights
├── Log using ILogger
├── Return HTTP Status Code
└── Return Standard JSON Response
Sample Response
{
"success": false,
"message": "Unexpected error occurred.",
"statusCode": 500
}
{
"success": false,
"message": "Unexpected error occurred.",
"statusCode": 500
}
Benefits
Centralized exception handling
Clean controllers
Consistent API responses
Better monitoring
Improved security (no stack trace exposed)
Centralized exception handling
Clean controllers
Consistent API responses
Better monitoring
Improved security (no stack trace exposed)
2. How did you use Azure Functions with Service Bus, Blob Storage, and Timer Triggers?
Interview Answer
"In one of my projects, we used Azure Functions for event-driven background processing. HTTP APIs accepted user requests and published messages to Azure Service Bus. A Service Bus-triggered Azure Function processed those messages asynchronously. For file uploads, we used Blob Storage triggers to process files automatically after they were uploaded. We also used Timer Trigger Functions for scheduled jobs such as report generation, cleanup tasks, and sending reminder emails."
"In one of my projects, we used Azure Functions for event-driven background processing. HTTP APIs accepted user requests and published messages to Azure Service Bus. A Service Bus-triggered Azure Function processed those messages asynchronously. For file uploads, we used Blob Storage triggers to process files automatically after they were uploaded. We also used Timer Trigger Functions for scheduled jobs such as report generation, cleanup tasks, and sending reminder emails."
Architecture
Client
│
▼
Web API
│
Publish Message
▼
Azure Service Bus
│
▼
Azure Function
│
Business Logic
▼
Azure SQL
Client
│
▼
Web API
│
Publish Message
▼
Azure Service Bus
│
▼
Azure Function
│
Business Logic
▼
Azure SQL
Blob Trigger Example
Upload File
│
Azure Blob Storage
│
Blob Trigger Function
│
Read File
│
Process Data
│
Save to Database
Upload File
│
Azure Blob Storage
│
Blob Trigger Function
│
Read File
│
Process Data
│
Save to Database
Timer Trigger Example
Runs automatically.
Every Night 2 AM
↓
Azure Function
↓
Generate Reports
↓
Send Email
↓
Cleanup Old Data
Benefits
Auto Scaling
Pay per execution
Decoupled architecture
Event-driven processing
Reduced API response time
Auto Scaling
Pay per execution
Decoupled architecture
Event-driven processing
Reduced API response time
3. How did you monitor Production using Application Insights?
Interview Answer
"We integrated Application Insights into all APIs and Azure Functions. It automatically captured request execution time, dependency calls, SQL queries, failed requests, exceptions, and performance metrics. We also logged custom business events and configured Azure Monitor alerts to notify the support team through email or Teams whenever exception counts or response times exceeded predefined thresholds."
"We integrated Application Insights into all APIs and Azure Functions. It automatically captured request execution time, dependency calls, SQL queries, failed requests, exceptions, and performance metrics. We also logged custom business events and configured Azure Monitor alerts to notify the support team through email or Teams whenever exception counts or response times exceeded predefined thresholds."
Monitored Items
API Requests
SQL Queries
HTTP Calls
Azure Service Bus Calls
Exceptions
CPU
Memory
Availability Tests
API Requests
SQL Queries
HTTP Calls
Azure Service Bus Calls
Exceptions
CPU
Memory
Availability Tests
Custom Logging
_logger.LogInformation("Order Created");
telemetryClient.TrackEvent("OrderPlaced");
_logger.LogInformation("Order Created");
telemetryClient.TrackEvent("OrderPlaced");
Alerts
Examples:
Response Time > 3 Seconds
Exception Count > 10
Failed Requests > 5%
CPU > 80%
Availability Test Failed
Dashboard
API
↓
Application Insights
↓
Azure Monitor
↓
Alerts
↓
Email / Teams Notification
API
↓
Application Insights
↓
Azure Monitor
↓
Alerts
↓
Email / Teams Notification
4. How did you design Microservices using Saga Pattern?
Interview Answer
"We implemented the Saga Pattern using Azure Service Bus to manage distributed transactions across microservices. Each service owned its own database and executed local transactions. Instead of distributed transactions, services communicated through events. If any step failed, compensating transactions were triggered to maintain data consistency."
"We implemented the Saga Pattern using Azure Service Bus to manage distributed transactions across microservices. Each service owned its own database and executed local transactions. Instead of distributed transactions, services communicated through events. If any step failed, compensating transactions were triggered to maintain data consistency."
Example
Customer Places Order
Order Service
│
Create Order
▼
Publish OrderCreated Event
↓
Payment Service
Charge Payment
↓
Inventory Service
Reserve Stock
↓
Shipping Service
Create Shipment
If Shipping Fails
Shipping Failed
│
▼
Publish Failure Event
│
▼
Inventory Release
│
Refund Payment
│
Cancel Order
Messaging
We used
Azure Service Bus Topics
Queues
Dead Letter Queue
Retry Policy
Benefits
Loose Coupling
Scalability
Event-driven
Eventual Consistency
Better fault tolerance
Loose Coupling
Scalability
Event-driven
Eventual Consistency
Better fault tolerance
5. How did you apply SOLID Principles and Dependency Injection?
Interview Answer
"While designing services, we followed SOLID principles to keep the code modular, testable, and maintainable. Business logic was separated into service classes, repositories handled data access, interfaces were used for abstractions, and dependencies were injected through the built-in Dependency Injection container."
"While designing services, we followed SOLID principles to keep the code modular, testable, and maintainable. Business logic was separated into service classes, repositories handled data access, interfaces were used for abstractions, and dependencies were injected through the built-in Dependency Injection container."
Example
Instead of
OrderService
↓
new PaymentService()
We used
OrderService
↓
IPaymentService
↓
PaymentService
Constructor Injection
public OrderService(IPaymentService paymentService)
{
_paymentService = paymentService;
}
public OrderService(IPaymentService paymentService)
{
_paymentService = paymentService;
}
SOLID Used
Single Responsibility
Each class has one responsibility.
Example
OrderService
Repository
EmailService
NotificationService
Open Closed
Added new payment methods without changing existing code.
Liskov
Any payment provider could replace another.
Interface Segregation
Created small interfaces.
IEmailService
ISMSService
IPaymentService
Dependency Inversion
Depended on interfaces instead of concrete classes.
Benefits
Easy Testing
Mocking
Maintainability
Loose Coupling
Better Readability
Easy Testing
Mocking
Maintainability
Loose Coupling
Better Readability
6. How did you optimize Performance?
Interview Answer
"We optimized performance at multiple levels. Database queries were tuned with proper indexing and optimized LINQ queries. Asynchronous programming using async/await improved scalability by preventing thread blocking. Frequently accessed data was cached using Azure Cache for Redis. We monitored performance using Application Insights and optimized slow SQL queries and API response times."
"We optimized performance at multiple levels. Database queries were tuned with proper indexing and optimized LINQ queries. Asynchronous programming using async/await improved scalability by preventing thread blocking. Frequently accessed data was cached using Azure Cache for Redis. We monitored performance using Application Insights and optimized slow SQL queries and API response times."
Optimizations
Async Await
Instead of
var data = repository.Get();
Used
var data = await repository.GetAsync();
Benefits
Non-blocking
Better scalability
More concurrent requests
LINQ Optimization
Avoid
context.Users.ToList().Where(x=>x.IsActive);
Better
context.Users.Where(x=>x.IsActive).ToList();
Reason
Filtering happens in SQL instead of memory.
Projection
Instead of
context.Users.ToList();
Use
context.Users.Select(x=>new UserDto())
Only required columns are fetched.
Indexing
Added indexes on
CustomerId
OrderId
CreatedDate
Status
Reduced query time significantly.
Redis Cache
Frequently used data
Product Catalog
Master Data
Configuration
Stored in Redis.
Benefits
Faster response
Reduced DB load
Profiling
Used
Application Insights
SQL Execution Plans
EF Core Logging
Azure Monitor
Found
Slow SQL Queries
Long-running APIs
Memory usage
Deadlocks
Dependency failures
Final Interview Summary (2-Minute Answer)
"In my recent projects, I developed ASP.NET Core microservices hosted on Azure. I implemented global exception handling using custom middleware, which centralized logging through ILogger and Application Insights while returning standardized error responses. We used Azure Functions with Service Bus triggers for asynchronous message processing, Blob triggers for file processing, and Timer triggers for scheduled jobs. Production systems were monitored with Application Insights and Azure Monitor, where we tracked requests, dependencies, exceptions, and configured alerts for failures and performance thresholds. For distributed workflows like order processing, we implemented the Saga pattern using Azure Service Bus, allowing each microservice to manage its own database and use compensating transactions for failures. Throughout the application, we followed SOLID principles and dependency injection to keep the code modular, loosely coupled, and easy to test. To improve performance, we used async/await for non-blocking operations, optimized LINQ queries to execute filtering in SQL, added database indexes, cached frequently accessed data with Redis, and continuously profiled APIs and database queries using Application Insights and SQL execution plans."
Q) Why is DDD used with Microservices?
"In my recent projects, I developed ASP.NET Core microservices hosted on Azure. I implemented global exception handling using custom middleware, which centralized logging through ILogger and Application Insights while returning standardized error responses. We used Azure Functions with Service Bus triggers for asynchronous message processing, Blob triggers for file processing, and Timer triggers for scheduled jobs. Production systems were monitored with Application Insights and Azure Monitor, where we tracked requests, dependencies, exceptions, and configured alerts for failures and performance thresholds. For distributed workflows like order processing, we implemented the Saga pattern using Azure Service Bus, allowing each microservice to manage its own database and use compensating transactions for failures. Throughout the application, we followed SOLID principles and dependency injection to keep the code modular, loosely coupled, and easy to test. To improve performance, we used async/await for non-blocking operations, optimized LINQ queries to execute filtering in SQL, added database indexes, cached frequently accessed data with Redis, and continuously profiled APIs and database queries using Application Insights and SQL execution plans."
DDD helps identify bounded contexts, and each bounded context can become an independent microservice. This keeps services loosely coupled, with clear ownership of business logic and data.
Q) How have you used DDD in your projects?
"In our .NET Core microservices application, we used DDD to organize business logic into domain entities, aggregates, and domain services. Each microservice represented a bounded context—for example, Order, Inventory, and Payment. The Order aggregate enforced business rules such as preventing orders without items. Repositories handled persistence using EF Core, while domain events were published through Azure Service Bus to notify other microservices. This approach improved maintainability, testing, and scalability by keeping business logic centralized and services loosely coupled."
No comments:
Post a Comment