Tuesday, June 17, 2025

Architecture level and Azure service_Inshort

 1. Azure implements a layered approach to data protection

Azure implements a layered approach to data protection, often referred to as "defense in depth," with seven key layers. These layers include physical security, identity and access management, perimeter security, network security, compute security, application security, and data controlsThis strategy ensures that even if one layer is compromised, other layers can still protect data. 
Here's a breakdown of the seven layers:

  1. 1. Physical Security:
    This layer focuses on securing the physical infrastructure where Azure services are hosted, including data centers and hardware. 
  2. 2. Identity and Access Management:
    This layer deals with controlling who has access to Azure resources. It involves authentication (verifying user identity) and authorization (granting permissions). 
  3. 3. Perimeter Security:
    This layer uses technologies like firewalls and DDoS protection to safeguard the network boundary from unauthorized access and attacks. 
  4. 4. Network Security:
    This layer focuses on securing the network traffic within Azure, using network security groups, virtual network appliances, and other tools to control access and prevent malicious traffic. 
  5. 5. Compute Security:
    This layer deals with securing the virtual machines and other compute resources in Azure. It includes measures like encryption, endpoint protection, and vulnerability management. 
  6. 6. Application Security:
    This layer focuses on protecting applications running on Azure. It involves measures like web application firewalls (WAF), input validation, and secure coding practices. 
  7. 7. Data Security:
    This layer focuses on protecting data at rest and in transit. It includes encryption, data loss prevention (DLP), and other measures to ensure data confidentiality, integrity, and availability. 

2. Azure AD
To implement Azure AD authentication for an Angular application interacting with a .NET Core API, you need to register both the Angular SPA and the .NET Core API as separate applications in Azure Active Directory (Azure AD)The Angular app will use MSAL.js for user authentication, and the API will be secured using Azure AD to validate incoming requests. 
Here's a breakdown of the process:
1. Register Applications in Azure AD:
  • Angular SPA:
    Register your Angular application as a Single Page Application (SPA) in Azure AD. This registration will include the redirect URI (e.g., http://localhost:4200) where Azure AD will send the authentication response. 
  • .NET Core API:
    Register your .NET Core API as a separate application in Azure AD. You'll need to expose an API for the Angular app to access, defining scopes (e.g., api://<your-api-app-id>/access_as_user). 
2. Configure Authentication in Angular (using MSAL.js):
  • Install the MSAL.js library: npm install @azure/msal-browser @azure/msal-angular. 
  • Configure MSAL with your Azure AD client ID, tenant ID, and redirect URI. 
  • Use MSAL to initiate the login flow, redirecting the user to Azure AD for authentication. 
  • Upon successful login, MSAL will provide an access token and ID token. 
3. Secure the .NET Core API:
  • Install the Microsoft.AspNetCore.Authentication.JwtBearer NuGet package. 
  • Configure JWT Bearer authentication in your API's Startup.cs or Program.cs, specifying the authority (Azure AD endpoint) and audience (your API's application ID URI). 
  • Apply the [Authorize] attribute to your API's controllers or actions to protect them. 
4. Access the API from Angular:
  • Include the access token in the Authorization header of your API requests (e.g., Bearer <your_access_token>). 
  • The .NET Core API will validate the access token against Azure AD using the configured JWT Bearer authentication. 
5. Token Validation in API:
  • The .NET Core API should validate the access token using the JwtSecurityTokenHandler and the public keys from Azure AD's OpenID configuration endpoint.
  • Ensure the token's audience ( aud claim) matches your API's application ID URI. 
Key Considerations:
  • Scopes and Permissions:
    Carefully define the scopes required by your Angular application and grant the appropriate permissions to the API. 
  • Token Validation:
    Implement robust token validation logic in your API to ensure the security of your application. 
  • Error Handling:
    Implement proper error handling in both the Angular application and the .NET Core API to gracefully handle authentication and authorization failures. 
  • User Experience:
    Provide a seamless user experience by handling login redirects and token acquisition efficiently. 
This detailed process outlines the steps for integrating Azure AD authentication between your Angular SPA and .NET Core API, ensuring secure and scalable access management for your users. 
3.Skip Middle ware 
-2

I am using asp.net core 6 WEBAPI project in which I have some custom middlewares listed below:

app.UseMiddleware<CustomMiddleware1>();
app.UseMiddleware<CustomMiddleware2>();
app.UseMiddleware<CustomMiddleware3>();

Now there is one condition check I want to add in the CustomMiddleware1 if that becomes true then I don't want to execute the other two middlewares.

Here is the code below:

public class CustomMiddleware1
{
    private readonly RequestDelegate _next;

    public CustomMiddleware1(RequestDelegate next)
    {
        _next = next;
    }

    public async Task Invoke(HttpContext context)
    {
        if (context.Request.Path == "/login")
        {
            await context.Response.WriteAsync("Bypassing other middleware for login route");
        }
        else
        {
            await _next(context);
        }
    }
}
4.Other design pattern

SOLID principles are a set of five guidelines for object-oriented programming that aim to make software more understandable, flexible, and maintainableThe acronym SOLID stands for Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion. These principles, introduced by Robert C. Martin, help developers create code that is easier to understand, modify, and extend. 
Here's a breakdown of each principle:
  • Single Responsibility Principle (SRP):
    A class should have only one reason to change. In other words, it should have only one job or responsibility. 
  • Open/Closed Principle (OCP):
    Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. This means you should be able to add new functionality without altering existing code. 
  • Liskov Substitution Principle (LSP):
    Subtypes must be substitutable for their base types without altering the correctness of the program. Essentially, if a class B inherits from class A, you should be able to use an instance of B wherever an instance of A is expected, without unexpected behavior. 
  • Interface Segregation Principle (ISP):
    Clients should not be forced to depend on methods they do not use. This means interfaces should be small and focused, rather than large and monolithic. 
  • Dependency Inversion Principle (DIP):
    High-level modules should not depend on low-level modules. Both should depend on abstractions. This promotes loose coupling and makes code more flexible. 
Besides SOLID, other important software design principles include:
  • DRY (Don't Repeat Yourself): Avoid redundancy in code by creating reusable components. 
  • KISS (Keep It Simple, Stupid): Keep designs and systems as simple as possible. 
  • YAGNI (You Ain't Gonna Need It): Don't implement features until they are actually needed. 
  • GRASP (General Responsibility Assignment Software Patterns): A set of guidelines for assigning responsibilities to objects, often used in conjunction with SOLID. 

       -----------------------------


Traditional Architectures

  1. Monolithic Architecture

    • Single-tiered application, tightly coupled.

    • All logic (UI, business, DB) in one deployable unit.

  2. Layered (N-Tier) Architecture

    • Common 3-tier: Presentation, Business Logic, Data Access.

    • Easy to manage, good for enterprise systems.

  3. Client-Server Architecture

    • Client (frontend) communicates with a centralized server.

    • Common in desktop/web applications.


🧩 Modern & Distributed Architectures

  1. Microservices Architecture

    • System split into small, independently deployable services.

    • Each service owns its own data and logic.

  2. Service-Oriented Architecture (SOA)

    • Similar to microservices but often more heavyweight (ESBs, contracts).

    • Services communicate via defined interfaces.

  3. Event-Driven Architecture

    • Components interact through events (publish/subscribe).

    • Loose coupling, good for asynchronous systems.

  4. Serverless Architecture

    • Applications run in stateless compute containers (like Azure Functions, AWS Lambda).

    • Fully managed infrastructure.

  5. Cloud-Native Architecture

    • Designed for scalability and resilience in cloud environments.

    • Uses containers, microservices, orchestration (e.g., Kubernetes).

  6. 🧠 Data & Intelligence Architectures

    1. Data-Centric Architecture

      • Emphasizes data flow and transformation.

      • Common in analytics and BI systems.

    2. Big Data Architecture

      • Handles large-scale data ingestion, storage, processing.

      • Tools: Hadoop, Spark, Kafka.

    3. Machine Learning (ML) Architecture

      • Includes data pipelines, model training, deployment (MLOps).


    🔒 Security & Enterprise Integration Architectures

    1. Zero Trust Architecture

      • Security-first; assumes breach, verifies every request.

    2. Enterprise Integration Architecture

      • Combines various systems (ERP, CRM, etc.) using ESBs or APIs.


    🧪 Emerging & Hybrid Architectures

    1. Hexagonal (Ports and Adapters) Architecture

      • Separates core logic from external interfaces (like DB, UI).

      • Promotes testability and flexibility.

    2. Clean Architecture

      • Similar to hexagonal but with stricter layering (Entities, Use Cases, Interfaces).

    3. Onion Architecture

      • Layered with a domain model at the core.

    4. Micro-frontend Architecture

      • Frontend equivalent of microservices.

      • Split UI into independently deployable parts.

    5. Edge Computing Architecture

      • Moves compute closer to data source (e.g., IoT).

      • Reduces latency.

  7. All Architecture diagram 

  8. # Diagram Name Description
    1 Logical Architecture Diagram Shows logical components (UI, services, databases) and how they interact. Technology agnostic.
    2 Physical Architecture Diagram Depicts the actual deployment on hardware or cloud (servers, load balancers, network, etc.).
    3 Deployment Diagram Detailed view of how software modules are deployed across servers or containers.
    4 Application Architecture Diagram Shows internal layers of the application: UI, BLL, DAL, API, etc.

    6 Data Flow Diagram (DFD) Represents how data moves through the system (Level 0 to Level 2).
    7 Component Diagram Shows how components (microservices/modules) interact. Often includes interfaces.

    .
    10 CI/CD Pipeline Diagram Shows automated build, test, and deployment pipelines (Azure DevOps, Jenkins, etc.).
    11 Sequence Diagram Explains step-by-step interaction between components for a specific use case or flow.
    12 Service Architecture Diagram (Microservices) Shows how microservices are structured, communicate, and are deployed.
    13 Infrastructure Diagram (Cloud) Focuses on cloud infrastructure: compute, storage, load balancing, monitoring, etc.
     







No comments:

Post a Comment