Here is a comprehensive list of 200 .NET microservices coding questions covering all core microservices concepts and cross-cutting concerns relevant for designing, building, deploying, and maintaining .NET-based distributed systems.
๐งฉ A. Microservices Fundamentals (20)
- Build a microservice in .NET 8 that exposes a simple CRUD API.
- Implement communication between two microservices using REST.
- How would you design microservices for an e-commerce application?
- Create a microservice that handles user registration and login.
- How do you isolate domain logic in a microservice?
- How to apply the "Single Responsibility Principle" in microservices?
- Design a service registry/discovery mechanism using custom middleware.
- Implement a service that handles file uploads and metadata separately.
- Build a stateless microservice and explain its benefits.
- Implement health check endpoints in .NET 8.
- Demonstrate versioning in a microservice API.
- Add Swagger/OpenAPI support to your microservices.
- Create a microservice that exposes gRPC endpoints.
- How do you secure gRPC between microservices?
- Design a microservice architecture for a banking system.
- Create a .NET microservice that uses hosted services.
- Build a modular monolith and later split into microservices.
- Demonstrate backward compatibility in microservice updates.
- Implement graceful shutdown in your .NET service.
- Implement async programming pattern in your microservice.
๐ B. Inter-Service Communication (20)
- Implement synchronous REST communication between services.
- Implement asynchronous communication using RabbitMQ.
- Set up Kafka and publish events from a .NET microservice.
- Use MassTransit to connect services using RabbitMQ.
- Design an event-driven architecture using Azure Service Bus.
- How to implement request-response with message queues?
- Implement the Outbox pattern in a .NET microservice.
- Demonstrate retry mechanism in HTTP communication.
- Build a messaging service that communicates with multiple consumers.
- Handle message duplication in event-driven microservices.
- How do you deal with transactional messages?
- Implement correlation IDs for distributed tracing.
- Build a distributed caching mechanism with Redis between services.
- Create a message handler pipeline using MediatR.
- How to use gRPC for inter-service communication in .NET 8?
- Demonstrate fallback communication using Polly.
- Implement the Choreography pattern using events.
- Implement Saga Orchestration pattern in .NET microservices.
- Use SignalR for real-time communication between microservices.
- How would you achieve consistency across services in a distributed system?
⚙️ C. Domain-Driven Design (DDD) (20)
- Implement Aggregate Root in a service.
- Use Value Objects in a domain model.
- Split Entity vs Aggregate in a domain model.
- Build a bounded context and show integration points.
- Use domain events within a microservice.
- Implement a simple CQRS pattern using MediatR.
- Implement a complex CQRS pattern with separate read/write databases.
- Use Unit of Work and Repository pattern in a domain.
- How would you handle domain logic validation?
- Demonstrate Anti-Corruption Layer between services.
- Create a shared kernel in DDD.
- How do you separate application and domain layers?
- Use dependency injection in domain service.
- Create a layered architecture within a microservice.
- Demonstrate contract-first development.
- How do you evolve domain models without breaking consumers?
- What is an eventual consistency model, and how do you handle it in code?
- Demonstrate Aggregate consistency with distributed transactions.
- Implement Specification pattern in DDD.
- Create a service that uses multiple bounded contexts.
๐ D. Security & Authentication (20)
- Implement OAuth 2.0 in a microservice.
- Set up IdentityServer with multiple services.
- Use JWT tokens for authentication between microservices.
- Secure REST APIs using custom middleware.
- Implement token validation in a gRPC microservice.
- Create a shared authentication service.
- Implement role-based access in a service.
- Use API gateway for authentication enforcement.
- Demonstrate how to use Azure AD in .NET microservices.
- Implement certificate-based authentication.
- Apply CORS policy in an API.
- Demonstrate rate limiting using ASP.NET Core middleware.
- Log and audit authentication failures.
- Implement refresh tokens using IdentityServer.
- Use Keycloak with .NET microservices.
- Secure secrets using Azure Key Vault.
- Implement IP whitelisting in .NET APIs.
- Demonstrate identity propagation across services.
- Secure service-to-service communication using mTLS.
- Build a custom authorization attribute.
๐งฐ E. Cross-Cutting Concerns (40)
- Centralized logging using Serilog + Elasticsearch.
- Implement distributed tracing using OpenTelemetry.
- Set up Application Insights for all services.
- How to implement correlation ID in logs.
- Create a shared logging library.
- Add structured logging with contextual metadata.
- Monitor microservices using Prometheus and Grafana.
- Setup circuit breaker using Polly.
- Implement retry and fallback policies using Polly.
- Configure centralized configuration using Consul.
- Use Azure App Configuration across services.
- Create health and readiness probes.
- Setup metrics collection for service performance.
- Enable telemetry and alerts.
- Use FluentValidation for request models.
- Build a wrapper for database retry logic.
- Add request/response logging middleware.
- Add model state validation filters.
- Build a common exception handling middleware.
- Implement a custom caching layer.
- Setup Redis distributed caching.
- Use output caching in ASP.NET Core.
- Implement input sanitization middleware.
- Configure Caching headers.
- Build an audit logging module.
- Capture API usage metrics.
- Create a background worker for message processing.
- Store logs to Azure Blob Storage.
- Use AppSettings.json + secrets.json + environment variables securely.
- Store configs in Azure Key Vault.
- Create a global exception handler in .NET.
- How to implement centralized exception tracking.
- Enable detailed error logging per environment.
- Use middleware to detect and block DoS patterns.
- Capture user activity logs.
- Build a metrics dashboard from service logs.
- Implement a request throttling mechanism.
- Design log aggregation strategy.
- Design a metrics collection and alert system.
- Apply GDPR logging compliance.
๐งช F. Testing & Resiliency (20)
- Write unit tests for a controller.
- Write integration tests for a microservice.
- Mock external API using WireMock or MockServer.
- Use xUnit and Moq to test service logic.
- Write tests for MediatR handlers.
- Test database interactions with Testcontainers.
- Perform contract testing using Pact.
- Validate API response using snapshot testing.
- Write BDD tests using SpecFlow.
- Create smoke tests for microservices.
- Setup chaos testing in .NET.
- Build resilience test cases.
- Test service with disabled downstream services.
- Simulate service failure and verify circuit breaker.
- Validate retry mechanism with failed requests.
- Stress test using k6.
- Implement unit tests for Domain Events.
- Perform fault injection and analyze logs.
- Use mocking to test Saga workflows.
- Test gRPC contracts with Protobuf verifier.
๐ G. Deployment & CI/CD (20)
- Containerize a microservice with Docker.
- Write Dockerfile for multi-stage .NET builds.
- Create docker-compose for multi-service app.
- Setup Kubernetes deployment for microservices.
- Use Helm to manage .NET microservices.
- Implement blue-green deployment strategy.
- Setup GitHub Actions for build and deploy.
- Configure Azure DevOps pipeline for microservice app.
- Deploy to Azure App Service with staging slots.
- Use Terraform to provision cloud infra.
- Build a pipeline that runs unit and integration tests.
- Push container to Azure Container Registry.
- Automate health check validation post-deploy.
- Configure rolling deployment in AKS.
- Setup Canary deployment for a new version.
- Enable zero downtime deployment strategy.
- Use Feature Flags with LaunchDarkly.
- Monitor deployments using Azure Monitor.
- Rollback failed deployments.
- Use Dapr for sidecar deployment pattern.
๐งฑ H. Patterns, Governance, and Architecture (20)
- Apply API Gateway pattern using YARP or Ocelot.
- Implement Backend-for-Frontend (BFF) pattern.
- Create Aggregator microservice.
- Design microservices around business capabilities.
- Apply the Strangler Fig pattern to break a monolith.
- Design microservices to support multitenancy.
- Use DDD + Event Sourcing + CQRS in a service.
- Apply hexagonal architecture in a microservice.
- Create a shared library with common models.
- Avoid tight coupling using DTOs.
- Explain data ownership between services.
- Use API contracts with version control.
- Implement eventual consistency using events.
- Avoid shared databases – demonstrate with example.
- Apply service mesh (Istio or Linkerd) to microservices.
- Secure public-facing vs internal APIs.
- Handle partial failures in distributed transactions.
- Apply 12-factor app principles in .NET apps.
- Maintain backward compatibility in message schemas.
- How do you handle schema evolution in contracts?
๐ฆ I. Database and Data Consistency (20)
- Design service with its own database.
- Demonstrate DB-per-service in a shopping cart scenario.
- Use EF Core in code-first approach.
- Use database migrations in .NET apps.
- Implement eventual consistency using delayed events.
- Implement shared read models.
- Use Dapper with repository pattern.
- Implement read optimization with Redis.
- Apply optimistic concurrency in EF Core.
- Handle distributed transactions using Saga pattern.
- Create snapshot store for event sourcing.
- Write audit logs to a separate database.
- Perform schema validation on startup.
- Use Cosmos DB with microservices.
- Secure data access using stored procedures.
- Implement sharding across services.
- Use PostgreSQL for identity service.
- Enforce foreign key constraints via code.
- How to perform bulk inserts efficiently in .NET?
- Handle failover and recovery in DB connections.
Comments
Post a Comment