> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ahmadraza.in/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Azure Infra

## AWS to Azure Infrastructure Mapping Design

### Infra in my AWS Mumbai Region `ap-south-1`

* Custom VPC which has 3 public subnets, each in 3 AZs, and 3 private subnets, each in 3 AZs.
  * Includes an **Internet Gateway** for public subnets and a **NAT Gateway** for private subnets.
* 1 **Frontend Server**, 1 **Checkout Server**, and 1 **Plugin Server** behind an **ALB** using host-based load balancing. The ALB does not have an auto-scaling group.
* 3 **Backend API Servers** behind an **ALB** with an **Auto-scaling Group** for scaling.
* 1 **RDS** for backend and 1 **Read Replica** for reads.
* 1 **Elasticache Redis** for backend caching.
* 1 **AWS MSK Kafka** for event streaming.
* 4 **S3 Buckets** for storage.

***

### Azure Infrastructure Setup

### Step 1: **Set Up the Network**

#### Equivalent Service in Azure: **Azure Virtual Network (VNet)**

1. **Create a VNet:**
   * Navigate to **Azure Portal** → Search for **Virtual Networks** → Click **Create**.
   * Name the VNet (e.g., `my-vnet`), select your **Region**, and define the **IP Address space**.

2. **Subnets:**
   * Add **3 public subnets** and **3 private subnets** across **3 Azure Availability Zones (AZs)**.
   * Public Subnet: Assign a portion of the IP range for the public subnets.
   * Private Subnet: Assign a separate portion for private subnets.

3. **Internet Gateway Equivalent:**
   * Azure uses **Public IP addresses** with **Network Security Groups (NSG)** to allow internet access.
   * For public subnets, associate them with **Public IP addresses**.

4. **NAT Gateway for Private Subnets:**
   * Create a **NAT Gateway** in Azure.
   * Associate the NAT Gateway with the private subnets for outbound internet access.

***

### Step 2: **Frontend, Checkout, and Plugin Servers**

#### Equivalent Service in Azure: **Azure Virtual Machines (VMs)** + **Azure Load Balancer**

1. **Deploy VMs:**
   * Navigate to **Azure Portal** → Search for **Virtual Machines** → Click **Create**.
   * Create three separate VMs for the frontend, checkout, and plugin servers.
   * Choose appropriate VM sizes based on workload.

2. **Azure Load Balancer:**
   * Use the **Azure Application Gateway** for **host-based routing** (similar to ALB in AWS).
   * Configure backend pools with the three servers.
   * Set up **Routing Rules** to route traffic based on hostnames (frontend, checkout, plugin).

***

### Step 3: **Backend API Servers**

#### Equivalent Service in Azure: **Azure Virtual Machines (VMs)** + **Azure VM Scale Sets**

1. **Deploy Backend Servers:**
   * Use **VM Scale Sets** to enable **autoscaling** for the backend servers.
   * Configure the scale set to maintain a minimum of 3 instances and scale based on CPU or memory thresholds.

2. **Azure Load Balancer:**
   * Create an **Azure Application Gateway** for the backend servers.
   * Configure the backend pool with the scale set.

***

### Step 4: **RDS with Read Replica**

#### Equivalent Service in Azure: **Azure Database for MySQL**

1. **Deploy Azure Database for MySQL:**
   * Navigate to **Azure Portal** → Search for **Azure Database for MySQL** → Click **Create**.
   * Choose **Flexible Server** for better control and high availability.
   * Configure the primary database.

2. **Read Replica:**
   * Once the primary database is deployed, configure **Read Replicas** via the Azure Database settings.

***

### Step 5: **ElastiCache Redis**

#### Equivalent Service in Azure: **Azure Cache for Redis**

1. **Deploy Azure Cache for Redis:**
   * Navigate to **Azure Portal** → Search for **Azure Cache for Redis** → Click **Create**.
   * Choose the appropriate tier (e.g., Standard or Premium) for production use.

***

### Step 6: **AWS MSK Kafka**

#### Equivalent Service in Azure: **Azure Event Hubs (Kafka-Compatible)**

1. **Deploy Event Hubs Namespace:**
   * Navigate to **Azure Portal** → Search for **Event Hubs** → Click **Create**.
   * Enable **Kafka Protocol** to make it compatible with your Kafka client.

2. **Create Topics:**
   * Set up topics in Event Hubs similar to your Kafka topics in AWS MSK.

***

### Step 7: **S3 Buckets**

#### Equivalent Service in Azure: **Azure Blob Storage**

1. **Deploy Storage Accounts:**
   * Navigate to **Azure Portal** → Search for **Storage Accounts** → Click **Create**.
   * Create 4 storage accounts or configure containers within a single storage account.

2. **Access Control:**
   * Use **Azure Blob Storage** access keys or SAS tokens for secure access.

***

### Additional Steps:

1. **Monitoring:**
   * Use **Azure Monitor** with **Log Analytics** to monitor your VMs, databases, and other components.

2. **Access Control:**
   * Use **Azure Active Directory (AAD)** for identity and access management.

3. **Resource Organization:**
   * Use **Resource Groups** to organize your resources by environment (e.g., Dev, Test, Prod).

***

### Mapping Summary:

| AWS Service       | Azure Equivalent             |
| ----------------- | ---------------------------- |
| VPC               | Azure Virtual Network (VNet) |
| Subnets           | Subnets                      |
| Internet Gateway  | Public IP + NSG              |
| NAT Gateway       | Azure NAT Gateway            |
| EC2               | Azure Virtual Machines (VMs) |
| ALB (host-based)  | Azure Application Gateway    |
| RDS MySQL         | Azure Database for MySQL     |
| ElastiCache Redis | Azure Cache for Redis        |
| MSK Kafka         | Azure Event Hubs             |
| S3                | Azure Blob Storage           |

***

### Infrastructure Diagrams

#### AWS Infrastructure Design:

```plaintext theme={null}
AWS VPC
|
|-- Public Subnets (x3 in AZs)
|   |-- Frontend Server
|   |-- Checkout Server
|   |-- Plugin Server
|   |-- ALB (Host-based Routing)
|
|-- Private Subnets (x3 in AZs)
    |-- Backend API Servers (Auto-scaling Group)
    |-- RDS (Primary + Read Replica)
    |-- Elasticache Redis
    |-- MSK Kafka
|
|-- S3 Buckets (x4)
```

#### Azure Infrastructure Design:

```plaintext theme={null}
Azure Virtual Network (VNet)
|
|-- Public Subnets (x3 in AZs)
|   |-- Frontend Server (VM)
|   |-- Checkout Server (VM)
|   |-- Plugin Server (VM)
|   |-- Application Gateway (Host-based Routing)
|
|-- Private Subnets (x3 in AZs)
    |-- Backend API Servers (VM Scale Set)
    |-- Azure Database for MySQL (Primary + Read Replica)
    |-- Azure Cache for Redis
    |-- Azure Event Hubs (Kafka-Compatible)
|
|-- Azure Blob Storage (x4)
```
