Wednesday, September 16, 2026

Terraform: Complete Guide with Real-Time Azure and .NET Microservices Example -2026


Introduction

In modern cloud-based application development, manually creating and configuring infrastructure through the Azure Portal, AWS Console, or other cloud management portals can become difficult as applications grow.

A typical enterprise .NET application may require multiple infrastructure components such as:

  • Azure Virtual Network

  • Azure Kubernetes Service (AKS)

  • Azure Container Registry (ACR)

  • Azure SQL Database

  • Azure Service Bus

  • Azure Key Vault

  • Azure API Management

  • Application Gateway

  • Application Insights

  • Azure Monitor

  • Storage Accounts

  • Managed Identities

Creating all these resources manually can be time-consuming and error-prone.

This is where Terraform becomes extremely useful.

Terraform allows us to define infrastructure using code and manage that infrastructure consistently across different environments such as:

  • Development

  • QA

  • UAT

  • Production

Terraform is an Infrastructure as Code (IaC) tool developed by HashiCorp.

Instead of manually creating infrastructure, we describe what infrastructure we need in Terraform configuration files, and Terraform creates and manages those resources for us.


1. What Is Terraform?

Terraform is an Infrastructure as Code tool used to provision and manage infrastructure using configuration files.

For example, instead of opening the Azure Portal and manually creating a Resource Group, we can write:

resource "azurerm_resource_group" "oneview" {
  name     = "rg-oneview-dev"
  location = "East US"
}

Terraform interprets this configuration and creates the corresponding Azure Resource Group.

The basic idea is:

Terraform Configuration
        |
        v
    Terraform
        |
        v
   Azure Provider
        |
        v
 Azure Infrastructure

Terraform can manage infrastructure from many platforms and services.

Examples include:

  • Microsoft Azure

  • Amazon Web Services

  • Google Cloud

  • Kubernetes

  • GitHub

  • Databases

  • Monitoring platforms

  • SaaS applications


2. What Is Infrastructure as Code?

Infrastructure as Code means managing infrastructure through machine-readable configuration files instead of manually configuring infrastructure.

Traditional Approach

Suppose we need to create an AKS cluster.

An engineer may manually:

  1. Open Azure Portal

  2. Create Resource Group

  3. Create Virtual Network

  4. Create Subnet

  5. Create AKS

  6. Configure networking

  7. Configure identity

  8. Configure permissions

  9. Configure monitoring

  10. Connect AKS with ACR

This process can be repeated for every environment.

Developer
    |
    v
Azure Portal
    |
    +--> Resource Group
    +--> VNet
    +--> Subnet
    +--> AKS
    +--> ACR
    +--> SQL
    +--> Service Bus

The problem is that manual configuration can introduce inconsistencies.

For example:

DEV  -> 2 AKS nodes
QA   -> 3 AKS nodes
UAT  -> 4 AKS nodes
PROD -> 6 AKS nodes

Some differences may be intentional, while others may happen because of manual configuration.

Infrastructure as Code Approach

With Terraform:

Terraform Code
      |
      v
Terraform Plan
      |
      v
Terraform Apply
      |
      v
Azure Infrastructure

The infrastructure configuration is stored in Git just like application source code.


3. Why Do We Need Terraform?

Terraform solves several infrastructure management problems.

3.1 Automation

Infrastructure can be created automatically.

3.2 Repeatability

The same infrastructure configuration can be reused for multiple environments.

3.3 Version Control

Terraform files can be stored in Git.

For example:

Git
 |
 +-- Terraform Code
 |
 +-- Version History
 |
 +-- Pull Requests
 |
 +-- Code Reviews

3.4 Consistency

Dev, QA, UAT, and Production can use standardized infrastructure modules.

3.5 Disaster Recovery

Infrastructure can be recreated from code when appropriate.

3.6 Collaboration

Multiple developers, architects, and DevOps engineers can work with the same infrastructure definition.


4. Terraform Architecture

The Terraform architecture can be represented as follows:

                Terraform Configuration
                         |
                         v
                  Terraform CLI
                         |
          +--------------+--------------+
          |                             |
          v                             v
   Terraform State                 Terraform Provider
                                        |
                                        v
                                  Azure APIs
                                        |
                                        v
                              Azure Infrastructure

The major components are:

  1. Terraform CLI

  2. Terraform Configuration

  3. Providers

  4. Resources

  5. Variables

  6. Data Sources

  7. State

  8. Backend

  9. Modules

  10. Outputs

Let's understand each one.


5. Terraform Configuration Files

Terraform configuration files generally use the .tf extension.

For example:

main.tf
variables.tf
outputs.tf
provider.tf
network.tf
aks.tf
sql.tf
servicebus.tf

Terraform reads all .tf files in the working directory.

Therefore, we don't have to put everything into one file.

A large enterprise project can be organized into multiple files.


6. HCL — HashiCorp Configuration Language

Terraform configurations are generally written using HCL.

For example:

resource "azurerm_resource_group" "oneview" {
  name     = "rg-oneview-dev"
  location = "East US"
}

The syntax is:

resource "RESOURCE_TYPE" "RESOURCE_NAME" {
    configuration
}

In this example:

resource
   |
   +-- azurerm_resource_group
   |
   +-- oneview

7. Terraform Providers

A provider allows Terraform to communicate with an external platform or service.

For Azure, we commonly use:

azurerm

Example:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 4.0"
    }
  }
}

provider "azurerm" {
  features {}
}

The provider acts as the bridge between Terraform and Azure.

Terraform
    |
    v
Azure Provider
    |
    v
Azure API
    |
    v
Azure Resources

8. Installing Terraform

After installing Terraform, verify the installation:

terraform version

You should see the installed Terraform version.

For Azure development, Azure CLI is also useful.

Check Azure CLI:

az version

Login to Azure:

az login

You can then select the required Azure subscription.

az account set --subscription "<subscription-id>"

9. Real-Time Project Example

Let's consider a real-world .NET application called:

OneView Workforce Planning Platform

Suppose OneView contains the following microservices:

  • Forecast Service

  • Workforce Service

  • Capacity Service

  • Hiring Service

A possible architecture is:

                         Users
                           |
                           v
                  Application Gateway
                           |
                           v
                  Azure API Management
                           |
          +----------------+----------------+
          |                |                |
          v                v                v
    Forecast API     Workforce API     Capacity API
          |                |                |
          +----------------+----------------+
                           |
                           v
                  Azure Service Bus
                           |
                           v
                     Hiring Service
                           |
                           v
                      Azure SQL

Supporting Azure services might include:

AKS
ACR
Azure SQL
Service Bus
Key Vault
API Management
Application Gateway
Application Insights
Azure Monitor
Virtual Network
Managed Identity

Terraform can provision much of this infrastructure.


10. Creating the Terraform Project

Let's create the following project structure:

oneview-infrastructure/
│
├── provider.tf
├── variables.tf
├── resource-group.tf
├── network.tf
├── acr.tf
├── aks.tf
├── servicebus.tf
├── outputs.tf
└── terraform.tfvars

For a larger enterprise project, we can later convert these resources into reusable modules.


11. Configure Azure Provider

Create:

provider.tf

Add:

terraform {
  required_version = ">= 1.6.0"

  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 4.0"
    }
  }
}

provider "azurerm" {
  features {}
}

This tells Terraform that the project uses the Azure Resource Manager provider.


12. Create Azure Resource Group

Create:

resource-group.tf
resource "azurerm_resource_group" "oneview" {
  name     = var.resource_group_name
  location = var.location

  tags = {
    Environment = var.environment
    Application = "OneView"
    ManagedBy   = "Terraform"
  }
}

Instead of hardcoding values, we are using variables.


13. Terraform Variables

Create:

variables.tf
variable "resource_group_name" {
  description = "Azure Resource Group name"
  type        = string
}

variable "location" {
  description = "Azure region"
  type        = string
  default     = "East US"
}

variable "environment" {
  description = "Deployment environment"
  type        = string
  default     = "dev"
}

variable "aks_node_count" {
  description = "Number of AKS nodes"
  type        = number
  default     = 2
}

Now create:

terraform.tfvars
resource_group_name = "rg-oneview-dev"
location            = "East US"
environment         = "dev"
aks_node_count      = 2

14. Terraform Init

Navigate to the project directory:

cd oneview-infrastructure

Run:

terraform init

Terraform downloads the required provider and initializes the working directory.

Typical flow:

Terraform Project
       |
       v
terraform init
       |
       v
Download Providers
       |
       v
Initialized

15. Terraform Validate

Before creating infrastructure, validate the configuration:

terraform validate

This checks the Terraform configuration for syntax and configuration errors.


16. Terraform Format

Terraform provides a formatting command:

terraform fmt

This automatically formats Terraform files according to Terraform's standard formatting rules.


17. Terraform Plan

Now execute:

terraform plan

Terraform calculates what changes are required.

For example:

Plan: 1 to add, 0 to change, 0 to destroy.

The important point is:

terraform plan previews changes.

It is normally used before applying infrastructure changes.


18. Terraform Apply

To create the infrastructure:

terraform apply

Terraform displays the planned changes and asks for confirmation.

Enter:

yes

Terraform then creates the resources.

You can also use:

terraform apply -auto-approve

However, automatic approval should be used carefully, especially for production environments.


19. Creating Azure Virtual Network

Now let's create networking.

Create:

network.tf
resource "azurerm_virtual_network" "oneview" {
  name                = "vnet-oneview"
  location            = azurerm_resource_group.oneview.location
  resource_group_name = azurerm_resource_group.oneview.name
  address_space       = ["10.10.0.0/16"]

  tags = {
    Environment = var.environment
    Application = "OneView"
    ManagedBy   = "Terraform"
  }
}

Create an AKS subnet:

resource "azurerm_subnet" "aks" {
  name                 = "snet-aks"
  resource_group_name  = azurerm_resource_group.oneview.name
  virtual_network_name = azurerm_virtual_network.oneview.name
  address_prefixes     = ["10.10.1.0/24"]
}

20. Creating Azure Container Registry

.NET microservices can be packaged as Docker containers.

Those container images can be stored in Azure Container Registry.

Create:

acr.tf
resource "azurerm_container_registry" "oneview" {
  name                = "acroneviewdev123"
  resource_group_name = azurerm_resource_group.oneview.name
  location            = azurerm_resource_group.oneview.location

  sku = "Standard"

  admin_enabled = false

  tags = {
    Environment = var.environment
    Application = "OneView"
    ManagedBy   = "Terraform"
  }
}

The application deployment flow becomes:

.NET Source Code
       |
       v
Docker Build
       |
       v
Container Image
       |
       v
Azure Container Registry
       |
       v
AKS

21. Creating Azure Kubernetes Service

Now let's create AKS.

Create:

aks.tf

Example:

resource "azurerm_kubernetes_cluster" "oneview" {

  name                = "aks-oneview-dev"
  location            = azurerm_resource_group.oneview.location
  resource_group_name = azurerm_resource_group.oneview.name
  dns_prefix          = "oneview-dev"

  default_node_pool {
    name       = "system"
    node_count = var.aks_node_count
    vm_size    = "Standard_D2s_v5"
  }

  identity {
    type = "SystemAssigned"
  }

  tags = {
    Environment = var.environment
    Application = "OneView"
    ManagedBy   = "Terraform"
  }
}

Terraform now understands that AKS belongs to the resource group.


22. Terraform Dependency Management

Terraform automatically identifies many dependencies by analyzing resource references.

For example:

resource_group_name = azurerm_resource_group.oneview.name

Terraform understands:

Resource Group
       |
       v
      AKS

Therefore, Terraform creates the Resource Group before AKS.

This is called an implicit dependency.


23. Explicit Dependencies

Sometimes Terraform cannot determine a dependency automatically.

In those cases, we can use:

depends_on = [
  azurerm_resource_group.oneview
]

Example:

resource "some_resource" "example" {

  # configuration

  depends_on = [
    azurerm_resource_group.oneview
  ]
}

It is generally preferable to rely on implicit dependencies whenever possible.


24. Connect AKS with ACR

AKS needs permission to pull container images from ACR.

We can assign the AcrPull role to the AKS kubelet identity.

Example:

resource "azurerm_role_assignment" "aks_acr" {

  principal_id = azurerm_kubernetes_cluster.oneview
    .kubelet_identity[0]
    .object_id

  role_definition_name = "AcrPull"

  scope = azurerm_container_registry.oneview.id

  skip_service_principal_aad_check = true
}

The relationship is:

Azure Container Registry
          |
          | AcrPull
          v
         AKS
          |
          v
      Kubernetes
          |
          v
       .NET Pods

25. Azure Service Bus with Terraform

In a microservices architecture, Azure Service Bus can be used for asynchronous communication.

Create:

servicebus.tf

Example:

resource "azurerm_servicebus_namespace" "oneview" {

  name                = "sb-oneview-dev"
  location            = azurerm_resource_group.oneview.location
  resource_group_name = azurerm_resource_group.oneview.name

  sku = "Standard"

  tags = {
    Environment = var.environment
    Application = "OneView"
    ManagedBy   = "Terraform"
  }
}

Create a topic:

resource "azurerm_servicebus_topic" "forecast_events" {

  name         = "forecast-events"
  namespace_id = azurerm_servicebus_namespace.oneview.id
}

Create a subscription:

resource "azurerm_servicebus_subscription" "workforce" {

  name               = "workforce-subscription"
  topic_id           = azurerm_servicebus_topic.forecast_events.id
  max_delivery_count = 10
}

The communication flow becomes:

Forecast Service
       |
       | ForecastCreated
       v
forecast-events
       |
       v
workforce-subscription
       |
       v
Workforce Service

26. Terraform Outputs

Create:

outputs.tf
output "resource_group_name" {
  value = azurerm_resource_group.oneview.name
}

output "aks_cluster_name" {
  value = azurerm_kubernetes_cluster.oneview.name
}

output "acr_login_server" {
  value = azurerm_container_registry.oneview.login_server
}

After applying the configuration:

terraform output

Terraform can display the output values.


27. Terraform State

One of the most important concepts in Terraform is state.

Terraform maintains information about infrastructure it manages.

The local state file is commonly:

terraform.tfstate

Conceptually:

Terraform Configuration
          |
          v
     Desired State
          |
          |
Terraform State
          |
          v
     Actual Azure

Terraform uses state to understand relationships between configuration and infrastructure.


28. Why Remote State Is Important

In a team environment, storing state only on an individual developer's machine is usually not appropriate.

Imagine:

Developer A
     |
Developer B
     |
Developer C
     |
Azure DevOps
     |
     v
Shared Terraform State

For Azure, an Azure Storage Account can be used as a remote backend.

Example:

terraform {
  backend "azurerm" {
    resource_group_name  = "rg-terraform-state"
    storage_account_name = "tfstateoneview"
    container_name       = "tfstate"
    key                  = "oneview-dev.tfstate"
  }
}

The backend infrastructure should generally be bootstrapped separately before configuring the project to use it.


29. Terraform State Locking

Consider this situation:

Developer A --------+
                    |
Developer B --------+----> Terraform State
                    |
CI/CD Pipeline -----+

If multiple operations modify the same state concurrently, problems can occur.

Remote backends can provide state locking or concurrency controls, depending on the backend.

Therefore, enterprise Terraform implementations should carefully design:

  • Remote state

  • State isolation

  • Locking

  • Access control

  • Backup

  • Recovery


30. Terraform Modules

As Terraform projects become larger, we should avoid putting hundreds or thousands of lines into a single file.

Terraform supports reusable modules.

Example:

terraform/
│
├── modules/
│   ├── network/
│   ├── aks/
│   ├── acr/
│   ├── sql/
│   ├── servicebus/
│   ├── keyvault/
│   └── apim/
│
└── environments/
    ├── dev/
    ├── qa/
    ├── uat/
    └── prod/

A module can encapsulate a reusable infrastructure component.


31. Example Terraform Module

Suppose we have an AKS module:

modules/
└── aks/
    ├── main.tf
    ├── variables.tf
    └── outputs.tf

The root configuration can call it:

module "aks" {

  source = "./modules/aks"

  resource_group_name = azurerm_resource_group.oneview.name
  location            = var.location
  node_count          = var.aks_node_count
}

The same module can then be reused by different environments.


32. Multiple Environments

A real enterprise application normally has:

DEV
QA
UAT
PROD

We can structure Terraform as:

environments/
│
├── dev/
│   ├── main.tf
│   └── terraform.tfvars
│
├── qa/
│   ├── main.tf
│   └── terraform.tfvars
│
├── uat/
│   ├── main.tf
│   └── terraform.tfvars
│
└── prod/
    ├── main.tf
    └── terraform.tfvars

For example:

Development

environment    = "dev"
aks_node_count = 2

Production

environment    = "prod"
aks_node_count = 5

The infrastructure module can remain reusable while environment-specific values are separated.


33. Terraform Data Sources

A Terraform resource creates or manages infrastructure.

A data source reads information about existing infrastructure.

For example:

data "azurerm_resource_group" "shared" {
  name = "rg-shared-services"
}

We can then access:

data.azurerm_resource_group.shared.location

This is particularly useful when an enterprise already has shared infrastructure.

For example:

Existing Shared Infrastructure
             |
      +------+------+
      |             |
      v             v
   Shared VNet   Key Vault
      |
      v
Application Terraform

Terraform doesn't necessarily need to create every resource itself.


34. Terraform Drift

Drift occurs when infrastructure changes outside Terraform.

Suppose Terraform defines:

AKS Node Count = 3

But someone manually changes Azure:

AKS Node Count = 5

Now:

Desired State = 3

Actual State = 5

This is infrastructure drift.

Running:

terraform plan

can reveal differences Terraform detects between the configuration/state and the infrastructure.


35. Terraform Import

Suppose an Azure resource already exists:

Azure Portal
     |
     v
Existing Resource

But Terraform doesn't currently manage it.

Terraform supports importing existing resources into Terraform state.

Conceptually:

Existing Azure Resource
          |
          v
    Terraform Import
          |
          v
   Terraform State

After import, you should ensure the Terraform configuration accurately represents the resource.

Modern Terraform also supports declarative import blocks for import workflows.


36. Terraform Lifecycle

Terraform provides lifecycle controls.

For example:

lifecycle {
  prevent_destroy = true
}

This can be useful for resources where accidental destruction would be especially undesirable.

Another lifecycle option is:

lifecycle {
  ignore_changes = [
    tags
  ]
}

Lifecycle rules should be used carefully because they can change Terraform's normal reconciliation behavior.


37. Terraform with Docker

Terraform and Docker solve different problems.

Docker

Docker packages applications into containers.

.NET Application
       |
       v
Docker Build
       |
       v
Container Image

Terraform

Terraform provisions infrastructure.

Terraform
    |
    +--> AKS
    +--> ACR
    +--> VNet
    +--> SQL
    +--> Service Bus

Together:

.NET Application
       |
       v
Docker Image
       |
       v
ACR
       |
       v
AKS
       ^
       |
 Terraform

38. Terraform with Kubernetes

Terraform and Kubernetes YAML also have different responsibilities.

Terraform can provision:

Azure
 |
 +--> VNet
 +--> AKS
 +--> ACR
 +--> SQL
 +--> Service Bus

Kubernetes can manage:

AKS
 |
 +--> Deployment
 +--> Service
 +--> Ingress
 +--> ConfigMap
 +--> Secret
 +--> HPA

Therefore:

Terraform
    |
    v
Infrastructure
    |
    v
AKS
    |
    v
Kubernetes
    |
    v
.NET Microservices

Terraform can also manage Kubernetes resources, but organizations often separate infrastructure provisioning from application deployment for operational clarity.


39. Terraform with Azure DevOps

Terraform becomes especially powerful when integrated with CI/CD.

A typical pipeline looks like:

Developer
    |
    v
Git Commit
    |
    v
Azure DevOps
    |
    +--> terraform fmt
    |
    +--> terraform validate
    |
    +--> terraform plan
    |
    v
Approval
    |
    v
terraform apply
    |
    v
Azure Infrastructure

40. Example Azure DevOps Terraform Pipeline

A simplified example:

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:

- task: TerraformInstaller@1
  inputs:
    terraformVersion: 'latest'

- script: |
    terraform init
  displayName: 'Terraform Init'

- script: |
    terraform fmt -check
  displayName: 'Terraform Format Check'

- script: |
    terraform validate
  displayName: 'Terraform Validate'

- script: |
    terraform plan
  displayName: 'Terraform Plan'

- script: |
    terraform apply -auto-approve
  displayName: 'Terraform Apply'

A production pipeline should additionally consider:

  • Azure service connections

  • Secure authentication

  • Remote state

  • Plan artifacts

  • Approval gates

  • Environment protection

  • Separate plan/apply stages

  • Secret management

  • Policy checks


41. Terraform and Security

Security is extremely important when managing infrastructure.

Never hardcode sensitive credentials:

password = "MyPassword123"

Instead, use mechanisms such as:

  • Azure Key Vault

  • Managed Identity

  • Workload Identity

  • Azure DevOps secret variables

  • Secure pipeline variables

  • Environment variables

For example:

Terraform
    |
    v
Azure Identity
    |
    v
Key Vault
    |
    v
Secrets

42. Sensitive Variables

Terraform supports sensitive variables.

Example:

variable "database_password" {
  type      = string
  sensitive = true
}

This helps prevent the value from being displayed in normal Terraform output.

However, marking a value as sensitive does not automatically remove it from Terraform state. Therefore, state itself must be securely stored and access-controlled.


43. Terraform Workspaces

Terraform supports workspaces.

For example:

terraform workspace new dev
terraform workspace new qa
terraform workspace new prod

Select a workspace:

terraform workspace select dev

Workspaces can be useful in certain scenarios, but for larger enterprise environments, separate environment directories and isolated remote states can sometimes provide clearer isolation.


44. Important Terraform Commands

CommandDescription
terraform initInitializes Terraform
terraform fmtFormats Terraform files
terraform validateValidates configuration
terraform planShows proposed changes
terraform applyCreates/updates infrastructure
terraform destroyDestroys managed infrastructure
terraform outputDisplays outputs
terraform showDisplays state/plan information
terraform state listLists resources in state
terraform state showShows a resource from state
terraform providersDisplays configured providers
terraform workspace listLists workspaces

45. Terraform Destroy

Terraform can also remove infrastructure that it manages.

terraform destroy

Terraform shows the resources it intends to destroy.

For example:

Plan: 0 to add, 0 to change, 10 to destroy.

After confirmation, Terraform removes the managed resources.

This command should be used with extreme care in production.


46. Terraform vs ARM Templates vs Bicep

For Azure architects, this is an important interview topic.

FeatureTerraformARM TemplatesBicep
ProviderHashiCorpMicrosoftMicrosoft
AzureYesYesYes
AWSYesNoNo
GCPYesNoNo
Multi-cloudStrongNoNo
SyntaxHCLJSONBicep
ModulesYesYesYes
Azure NativeNoYesYes
CI/CDYesYesYes

Bicep is an Azure-native Infrastructure as Code language.

Terraform is particularly attractive when an organization wants a common IaC approach across multiple providers or already has a mature Terraform ecosystem.


47. Terraform vs Ansible

Terraform and Ansible are also frequently compared.

Terraform

Primarily focuses on infrastructure provisioning.

Terraform
    |
    +--> Network
    +--> VM
    +--> AKS
    +--> Database
    +--> Storage

Ansible

Primarily focuses on configuration and automation.

Ansible
    |
    +--> Install packages
    +--> Configure servers
    +--> Deploy configuration
    +--> Execute operational tasks

Simplified:

Terraform
    |
    v
Provision Infrastructure

Ansible
    |
    v
Configure / Automate Systems

48. Terraform vs Docker vs Kubernetes

These three technologies solve different problems.

Terraform
    |
    v
Infrastructure Provisioning

Docker
    |
    v
Application Containerization

Kubernetes
    |
    v
Container Orchestration

For a .NET microservices platform:

Terraform
    |
    +--> Azure VNet
    +--> AKS
    +--> ACR
    +--> SQL
    +--> Service Bus
    |
    v
Docker
    |
    v
.NET Container
    |
    v
ACR
    |
    v
Kubernetes / AKS
    |
    v
Running Microservices

49. Complete OneView Terraform Architecture

Let's put everything together.

                         Internet
                            |
                            v
                  Application Gateway
                            |
                            v
                   Azure API Management
                            |
                            v
                           AKS
                            |
          +-----------------+-----------------+
          |                 |                 |
          v                 v                 v
    Forecast API      Workforce API     Capacity API
          |                 |                 |
          +-----------------+-----------------+
                            |
                            v
                    Azure Service Bus
                            |
                            v
                     Hiring Service
                            |
                            v
                       Azure SQL


Supporting Azure Services
-------------------------

        +-----------------------------+
        | Azure Container Registry    |
        | Azure Key Vault             |
        | Application Insights        |
        | Azure Monitor               |
        | Managed Identity             |
        | Virtual Network             |
        +-----------------------------+

                 ^
                 |
              Terraform
                 |
                 v
          Infrastructure as Code

50. End-to-End Terraform Deployment Flow

A complete enterprise deployment can look like:

                     Developer
                         |
                         v
                  Git Repository
                         |
                         v
                  Azure DevOps
                         |
            +------------+------------+
            |                         |
            v                         v
       Terraform                  Application
          Code                       Code
            |                         |
            v                         v
    terraform validate          Docker Build
            |                         |
            v                         v
      terraform plan               ACR
            |                         |
            v                         v
        Approval                    AKS
            |
            v
    terraform apply
            |
            v
      Azure Infrastructure
            |
     +------+------+------+
     |      |      |      |
     v      v      v      v
    VNet   AKS    SQL   Service Bus

51. Enterprise Terraform Repository Structure

A production-style Terraform repository can look like:

terraform-infrastructure/
│
├── modules/
│   │
│   ├── network/
│   │   ├── main.tf
│   │   ├── variables.tf
│   │   └── outputs.tf
│   │
│   ├── aks/
│   │   ├── main.tf
│   │   ├── variables.tf
│   │   └── outputs.tf
│   │
│   ├── acr/
│   ├── sql/
│   ├── servicebus/
│   ├── keyvault/
│   ├── apim/
│   └── monitoring/
│
├── environments/
│   │
│   ├── dev/
│   │   ├── main.tf
│   │   ├── variables.tf
│   │   └── terraform.tfvars
│   │
│   ├── qa/
│   │
│   ├── uat/
│   │
│   └── prod/
│
└── pipelines/
    ├── terraform-plan.yml
    └── terraform-apply.yml

This structure provides:

Reusable Modules
       +
Environment Isolation
       +
CI/CD Automation
       +
Version Control

52. Terraform Best Practices

1. Use Remote State

Use an appropriate remote backend instead of relying on local state for team-managed infrastructure.

2. Use Modules

Create reusable modules for common infrastructure components.

3. Never Hardcode Secrets

Use Key Vault, managed identities, and secure CI/CD mechanisms.

4. Use Git

Store Terraform code in source control.

5. Review Terraform Plans

Use:

terraform plan

before applying important infrastructure changes.

6. Use Environment Isolation

Separate development and production state appropriately.

7. Use Naming Standards

For example:

rg-oneview-dev
rg-oneview-qa
rg-oneview-uat
rg-oneview-prod

8. Use Resource Tags

tags = {
  Application = "OneView"
  Environment = "Production"
  Owner       = "PlatformTeam"
  ManagedBy   = "Terraform"
}

9. Implement CI/CD

Terraform should be integrated with your organization's DevOps process.

10. Protect Production

Production infrastructure should have:

  • Approval processes

  • Restricted permissions

  • Remote state

  • Secure credentials

  • Policy validation

  • Monitoring

  • Backup/recovery processes


53. Terraform in a .NET Solution Architect's Architecture

From a Solution Architect perspective, Terraform is not responsible for writing the .NET application.

Instead, it manages the infrastructure required to run the application.

For example:

                   .NET Application
                         |
                         v
                    Docker Image
                         |
                         v
                         ACR
                         |
                         v
                        AKS
                         |
       +-----------------+----------------+
       |                 |                |
       v                 v                v
 Forecast           Workforce         Capacity
 Service             Service           Service
       |                 |                |
       +-----------------+----------------+
                         |
                         v
                  Service Bus
                         |
                         v
                   Hiring Service
                         |
                         v
                    Azure SQL


Terraform manages:
-------------------

VNet
AKS
ACR
SQL
Service Bus
Key Vault
APIM
Application Gateway
Monitoring
Identity

This separation is important.

Application code describes what the application does.

Terraform describes what infrastructure the application needs.


54. Real-World Scenario

Suppose a company wants to create a new production environment for OneView.

Without Terraform:

Engineer
   |
   +--> Create Resource Group
   +--> Create VNet
   +--> Create Subnets
   +--> Create ACR
   +--> Create AKS
   +--> Create SQL
   +--> Create Service Bus
   +--> Create Key Vault
   +--> Configure APIM
   +--> Configure Monitoring
   +--> Configure Permissions

With Terraform:

Terraform Repository
        |
        v
terraform plan
        |
        v
Approval
        |
        v
terraform apply
        |
        v
Azure Infrastructure

The infrastructure definition becomes repeatable, reviewable, and version controlled.


55. Terraform Workflow — Summary

The standard Terraform workflow is:

             Write Terraform Code
                      |
                      v
              terraform init
                      |
                      v
             terraform fmt
                      |
                      v
           terraform validate
                      |
                      v
              terraform plan
                      |
                      v
                 Review
                      |
                      v
             terraform apply
                      |
                      v
             Azure Resources
                      |
                      v
             Monitor / Maintain
                      |
                      v
               Code Changes
                      |
                      v
             terraform plan

56. Important Terraform Concepts for Interviews

If you are preparing for a .NET Solution Architect, Azure Architect, or DevOps interview, the following Terraform topics are particularly important:

Terraform Fundamentals

  • What is Terraform?

  • What is Infrastructure as Code?

  • What is HCL?

  • What is a provider?

  • What is a resource?

  • What is a data source?

  • What is a variable?

  • What is an output?

State Management

  • What is Terraform state?

  • Why is state required?

  • What is remote state?

  • What is state locking?

  • What is state drift?

  • How do you secure Terraform state?

Modules

  • What is a Terraform module?

  • Why use modules?

  • How do you create reusable modules?

  • How do you pass variables into modules?

  • How do modules expose outputs?

Enterprise

  • Terraform with Azure DevOps

  • Terraform with AKS

  • Terraform with ACR

  • Terraform with Azure SQL

  • Terraform with Service Bus

  • Terraform with Key Vault

  • Terraform with API Management

  • Terraform with Application Gateway

  • Terraform with Managed Identity

  • Terraform with Azure Monitor


57. Key Takeaways

Terraform provides a consistent way to manage cloud infrastructure through code.

The most important concepts are:

Terraform
   |
   +--> Infrastructure as Code
   |
   +--> Providers
   |
   +--> Resources
   |
   +--> Variables
   |
   +--> Data Sources
   |
   +--> State
   |
   +--> Remote Backend
   |
   +--> Modules
   |
   +--> Outputs
   |
   +--> Plan
   |
   +--> Apply
   |
   +--> Destroy

For a modern .NET microservices application:

Terraform
    |
    +--> Azure Infrastructure
             |
             +--> VNet
             +--> AKS
             +--> ACR
             +--> Azure SQL
             +--> Service Bus
             +--> Key Vault
             +--> APIM
             +--> Application Gateway
             +--> Monitoring

The application itself can then be built using:

.NET
  |
  v
Docker
  |
  v
ACR
  |
  v
AKS

Therefore, Terraform plays an important role in creating a repeatable and automated cloud foundation for modern .NET applications.


Conclusion

Terraform is much more than a tool for creating Azure resources.

In an enterprise environment, Terraform can become an important part of the overall Cloud Infrastructure and DevOps strategy.

A typical modern architecture can combine:

.NET
 +
Docker
 +
Kubernetes / AKS
 +
Azure
 +
Terraform
 +
Azure DevOps

where:

  • .NET develops the business applications

  • Docker packages applications into containers

  • AKS orchestrates containers

  • Azure provides cloud infrastructure and managed services

  • Terraform provisions and manages infrastructure as code

  • Azure DevOps automates the CI/CD lifecycle

The result is a repeatable, automated, version-controlled infrastructure platform that can support development through production environments.

Terraform + Azure + .NET + Kubernetes + DevOps is therefore a powerful combination for building and operating modern enterprise applications.


Monday, August 31, 2026

Azure Red Hat OpenShift (ARO) with .NET Core — Complete Guide with Real-Time Example

 

Important clarification: Azure Red Hat OpenShift (ARO) is not mandatory for .NET Core/.NET applications. It is an enterprise container platform that can be an excellent choice when an organization wants OpenShift/Kubernetes capabilities with Azure-managed infrastructure. Microsoft describes ARO as a fully managed OpenShift service jointly operated and supported by Microsoft and Red Hat. (Microsoft Learn)


1. What is Azure Red Hat OpenShift?

Azure Red Hat OpenShift (ARO) is Microsoft's managed Red Hat OpenShift service running on Azure.

In simple terms:

.NET Application
       ↓
Docker Container
       ↓
OpenShift
       ↓
Azure Red Hat OpenShift
       ↓
Microsoft Azure

OpenShift extends Kubernetes with additional enterprise capabilities and developer/operator tooling. ARO gives you those OpenShift capabilities without requiring your team to manually operate the underlying OpenShift control plane and infrastructure. Microsoft and Red Hat jointly engineer, operate, and support the service. (Microsoft Learn)

ARO clusters are deployed into your Azure subscription, while Microsoft and Red Hat handle major platform-management responsibilities such as patching and monitoring of the managed cluster components. (Microsoft Learn)


2. Why do we need OpenShift?

Imagine an organization has 50 microservices:

                    API Gateway
                        |
        +---------------+---------------+
        |               |               |
   Order Service   Payment Service   Customer Service
        |               |               |
      SQL DB          SQL DB          Redis
        |
   Notification
      Service

Each service may have:

  • Different deployments

  • Different versions

  • Different resource requirements

  • Multiple replicas

  • Health checks

  • Networking requirements

  • Secrets

  • Configuration

  • Logging

  • Monitoring

  • Autoscaling

Managing all of this manually becomes difficult.

A container orchestration platform can manage these workloads.

OpenShift provides Kubernetes-based orchestration plus additional platform capabilities. ARO packages this as a managed Azure service. (Microsoft Learn)


3. Is Azure OpenShift mandatory for .NET Core?

❌ No.

This is one of the most important points.

A .NET application can run on:

IIS
Azure App Service
Azure Container Apps
Azure Kubernetes Service
Azure Red Hat OpenShift
Windows Services
Linux
Docker
Virtual Machines
On-premises servers

For example:

ASP.NET Core Web API
       |
       +----> IIS
       |
       +----> Azure App Service
       |
       +----> Docker
       |
       +----> AKS
       |
       +----> ARO

So .NET does not require OpenShift.

The decision depends on your organization's architecture, operational requirements, existing platform standards, compliance requirements, and team expertise.


4. Why would an enterprise choose ARO?

ARO becomes particularly interesting when an organization wants:

1. Kubernetes

OpenShift is built on Kubernetes.

2. Enterprise OpenShift platform

Organizations that already standardize on Red Hat OpenShift can use ARO while keeping their workloads on Azure.

3. Managed platform

Microsoft and Red Hat manage important parts of the platform, reducing the amount of cluster administration required from application teams. (Microsoft Learn)

4. Containerized microservices

.NET applications can be packaged as containers and deployed as independent workloads.

5. Scaling

Multiple replicas of a service can run simultaneously.

6. Security and identity

ARO supports integration with Microsoft Entra ID and Kubernetes RBAC. (Microsoft Learn)

7. CI/CD

It can be integrated with enterprise CI/CD pipelines.

8. Hybrid-cloud strategy

OpenShift can be useful for organizations that want consistency between OpenShift environments across different infrastructure.


5. ARO Architecture

A simplified architecture looks like this:

                   Internet
                      |
                      ↓
                Azure Front Door
                      |
                      ↓
             Application Gateway
                      |
                      ↓
             Azure Red Hat OpenShift
              ┌───────────────────┐
              │    OpenShift      │
              │     Cluster       │
              │                   │
              │  ┌─────────────┐  │
              │  │   Router    │  │
              │  └──────┬──────┘  │
              │         │         │
              │  ┌──────┴──────┐  │
              │  │   Service   │  │
              │  └──────┬──────┘  │
              │         │         │
              │   ┌─────┴─────┐   │
              │   │   Pods    │   │
              │   │           │   │
              │   │ .NET API  │   │
              │   │ .NET API  │   │
              │   │ .NET API  │   │
              │   └───────────┘   │
              └───────────────────┘
                       |
                Azure SQL Database

ARO provides single-tenant, high-availability OpenShift clusters on Azure. (Microsoft Learn)


6. Important OpenShift Terminology

Before deploying .NET, understand these concepts.

Cluster

The complete OpenShift environment.

ARO Cluster
   |
   +-- Control Plane
   |
   +-- Worker Nodes
   |
   +-- Networking
   |
   +-- Storage
   |
   +-- Operators

Node

A node is a machine that runs workloads.

Worker Node
   |
   +-- Pod
   +-- Pod
   +-- Pod

Pod

A Pod is the basic Kubernetes/OpenShift unit in which containers run.

For a simple .NET API:

Pod
 |
 +-- .NET Container

If you have three replicas:

Pod 1 → .NET API
Pod 2 → .NET API
Pod 3 → .NET API

Deployment

Defines how your application should be deployed.

For example:

replicas: 3

means we want three instances.


Service

Provides stable networking to the Pods.

             Service
                |
       +--------+--------+
       |        |        |
      Pod      Pod      Pod

Route

OpenShift Route exposes an application outside the cluster.

Internet
   |
   ↓
OpenShift Route
   |
   ↓
Service
   |
   ↓
Pods

7. Real-Time .NET Microservices Example

Let's design an e-commerce application.

We have:

E-Commerce
    |
    +-- Product Service
    |
    +-- Order Service
    |
    +-- Payment Service
    |
    +-- Inventory Service
    |
    +-- Notification Service

Suppose the Order Service is built using:

ASP.NET Core Web API
.NET 10
C#
Entity Framework Core
SQL Server
Docker

We want:

                 Client
                   |
                   ↓
              OpenShift
                   |
             Order Service
                   |
        +----------+----------+
        |          |          |
        ↓          ↓          ↓
    Payment    Inventory   Notification

8. Create the .NET API

Create the project:

dotnet new webapi -n OrderService
cd OrderService

Example API:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();

var app = builder.Build();

app.MapControllers();

app.Run();

Controller:

using Microsoft.AspNetCore.Mvc;

namespace OrderService.Controllers;

[ApiController]
[Route("api/orders")]
public class OrdersController : ControllerBase
{
    [HttpGet("{id}")]
    public IActionResult GetOrder(int id)
    {
        return Ok(new
        {
            OrderId = id,
            Product = "Laptop",
            Quantity = 2,
            Status = "Confirmed"
        });
    }
}

Now:

GET /api/orders/1001

returns:

{
  "orderId": 1001,
  "product": "Laptop",
  "quantity": 2,
  "status": "Confirmed"
}

9. Containerize the .NET Application

OpenShift runs containerized workloads, so we can create a Docker image for our API.

Example Dockerfile:

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

WORKDIR /src

COPY . .

RUN dotnet restore

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

FROM mcr.microsoft.com/dotnet/aspnet:10.0

WORKDIR /app

COPY --from=build /app/publish .

EXPOSE 8080

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

The basic flow becomes:

C# Code
   ↓
dotnet publish
   ↓
Docker Image
   ↓
Container Registry
   ↓
OpenShift
   ↓
Pod

10. Build the Docker Image

docker build -t orderservice:1.0 .

Test locally:

docker run -p 8080:8080 orderservice:1.0

Then:

http://localhost:8080/api/orders/1001

11. Push Image to Container Registry

In an enterprise environment, you could use a container registry such as:

Azure Container Registry

Conceptually:

docker tag orderservice:1.0 \
    myregistry.azurecr.io/orderservice:1.0

docker push \
    myregistry.azurecr.io/orderservice:1.0

Now the image is available to OpenShift.


12. Deploy the .NET Application to OpenShift

A Kubernetes/OpenShift Deployment could look like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: order-service
spec:
  replicas: 3

  selector:
    matchLabels:
      app: order-service

  template:
    metadata:
      labels:
        app: order-service

    spec:
      containers:
        - name: order-service

          image: myregistry.azurecr.io/orderservice:1.0

          ports:
            - containerPort: 8080

          resources:
            requests:
              cpu: "250m"
              memory: "256Mi"

            limits:
              cpu: "500m"
              memory: "512Mi"

Notice:

replicas: 3

OpenShift will run three Pods.

             Order Service
                   |
       +-----------+-----------+
       |           |           |
       ↓           ↓           ↓
     Pod 1       Pod 2       Pod 3

If one Pod becomes unavailable, the platform can maintain the desired replica state.


13. Create an OpenShift Service

Create:

apiVersion: v1
kind: Service

metadata:
  name: order-service

spec:
  selector:
    app: order-service

  ports:
    - port: 80
      targetPort: 8080

Now:

Service
   |
   +---- Pod 1
   |
   +---- Pod 2
   |
   +---- Pod 3

The application doesn't need to know which Pod receives the request.


14. Expose the API using an OpenShift Route

Example:

apiVersion: route.openshift.io/v1
kind: Route

metadata:
  name: order-service

spec:
  to:
    kind: Service
    name: order-service

  port:
    targetPort: 8080

The resulting flow is:

Client
  |
  | HTTPS
  ↓
OpenShift Route
  |
  ↓
Service
  |
  +--------+--------+
  |        |        |
 Pod 1    Pod 2    Pod 3

15. Deploy Using oc

OpenShift provides the oc command-line client.

For example:

oc login <your-cluster>

Create/select a project:

oc new-project ecommerce

Deploy:

oc apply -f deployment.yaml

Service:

oc apply -f service.yaml

Route:

oc apply -f route.yaml

Check Pods:

oc get pods

Example:

NAME                             READY   STATUS
order-service-7c8d9f7c5d-abc12   1/1     Running
order-service-7c8d9f7c5d-def34   1/1     Running
order-service-7c8d9f7c5d-ghi56   1/1     Running

16. What Happens When Traffic Increases?

Suppose:

Normal traffic
   ↓
3 Pods

During a festival sale:

Traffic increases
       ↓
Autoscaling
       ↓
5 Pods
       ↓
10 Pods

Conceptually:

              Service
                 |
       +---------+---------+
       |         |         |
      Pod       Pod       Pod
       |         |         |
       +---------+---------+
                 |
            More traffic
                 ↓
          Additional Pods

This is one of the major advantages of container orchestration.


17. Health Checks

A production .NET application shouldn't simply be considered healthy because its process is running.

ASP.NET Core provides health-check support.

Example:

builder.Services.AddHealthChecks();

var app = builder.Build();

app.MapHealthChecks("/health");

app.MapControllers();

app.Run();

Now:

GET /health

can be used by the platform to determine application health.


18. Configure Kubernetes/OpenShift Probes

For example:

livenessProbe:
  httpGet:
    path: /health
    port: 8080

  initialDelaySeconds: 10
  periodSeconds: 10

readinessProbe:
  httpGet:
    path: /health
    port: 8080

  initialDelaySeconds: 5
  periodSeconds: 5

There are two important concepts:

Liveness

"Is my application alive?"

Readiness

"Can my application receive traffic?"

This distinction is extremely important in microservices.


19. Configuration Management

Don't hard-code:

var connectionString =
    "Server=production-server;Database=Orders...";

Instead use configuration:

var connectionString =
    builder.Configuration.GetConnectionString("OrdersDb");

Environment-specific values can then be supplied through OpenShift configuration mechanisms.

For example:

env:
  - name: ASPNETCORE_ENVIRONMENT
    value: Production

  - name: ConnectionStrings__OrdersDb
    valueFrom:
      secretKeyRef:
        name: orders-db-secret
        key: connection-string

20. Secrets

Never put passwords directly into:

Dockerfile
Git repository
deployment.yaml
source code

Instead use a Secret.

Example:

oc create secret generic orders-db-secret \
  --from-literal=connection-string="YOUR-CONNECTION-STRING"

Then the application can consume it through an environment variable.

For enterprise Azure environments, you can also integrate workloads with Azure identity capabilities rather than relying on long-lived credentials. ARO supports managed and workload identities. (Microsoft Learn)


21. Scaling a .NET Microservice

Suppose:

Order Service
Current replicas = 3

You can scale manually:

oc scale deployment/order-service --replicas=5

Now:

Order Service
     |
     +-- Pod 1
     +-- Pod 2
     +-- Pod 3
     +-- Pod 4
     +-- Pod 5

In production, autoscaling can be configured based on resource utilization and other supported metrics.


22. Rolling Deployment

Suppose version 1.0 is running:

Pod 1 → v1
Pod 2 → v1
Pod 3 → v1

You deploy:

v2

The platform can perform a rolling update rather than stopping every instance simultaneously.

Conceptually:

Pod 1 → v2
Pod 2 → v1
Pod 3 → v1

Pod 1 → v2
Pod 2 → v2
Pod 3 → v1

Pod 1 → v2
Pod 2 → v2
Pod 3 → v2

This helps reduce application downtime during deployments.


23. Real-Time E-Commerce Architecture

Now let's put everything together.

                         Customers
                             |
                             ↓
                    Azure Front Door
                             |
                             ↓
                    OpenShift Route
                             |
                             ↓
                      API Gateway
                             |
       +---------------------+---------------------+
       |                     |                     |
       ↓                     ↓                     ↓
 Order Service        Product Service       Customer Service
       |                     |                     |
       ↓                     ↓                     ↓
 Payment Service       Inventory Service      Redis
       |
       ↓
 Notification Service
       |
       ↓
 Azure Service Bus

Each microservice can have:

.NET API
   ↓
Docker Image
   ↓
Container Registry
   ↓
OpenShift Deployment
   ↓
Pods
   ↓
Service
   ↓
Route

24. How .NET and OpenShift Work Together

The relationship is important to understand:

.NET
 ↓
Application Framework

Docker
 ↓
Application Packaging

Kubernetes
 ↓
Container Orchestration

OpenShift
 ↓
Enterprise Kubernetes Platform

Azure Red Hat OpenShift
 ↓
Managed OpenShift on Azure

So ARO isn't replacing .NET.

It provides the platform on which your containerized .NET applications can run.


25. OpenShift vs AKS

This is a very common interview question.

FeatureAKSAzure Red Hat OpenShift
TechnologyKubernetesOpenShift/Kubernetes
Azure managed serviceYesYes
MicrosoftManaged serviceJointly operated with Red Hat
Red Hat ecosystemNot centralStrong
OpenShift toolingNoYes
Kubernetes workloadsYesYes
.NET supportYesYes
Enterprise OpenShift standardNoYes
Best fitAzure/Kubernetes environmentsOrganizations standardized on OpenShift

Microsoft explicitly describes ARO as an Azure-managed OpenShift service jointly engineered, operated, and supported by Microsoft and Red Hat. (Microsoft Learn)


26. OpenShift vs Azure App Service

These solve different problems.

Azure App Service

Best when:

I have a web application/API
        ↓
I want managed hosting
        ↓
I don't need Kubernetes

ARO

Better suited when:

I have many containerized services
        ↓
I need Kubernetes/OpenShift
        ↓
I need enterprise container orchestration

Don't introduce OpenShift simply because you are using .NET.


27. OpenShift vs Docker

Another common misunderstanding:

Docker and OpenShift are not competitors in the same sense.

Docker packages the application.

OpenShift orchestrates containerized workloads.

.NET Application
       ↓
Docker Image
       ↓
OpenShift
       ↓
Pods
       ↓
Services
       ↓
Routes

28. Why .NET Applications Work Well on OpenShift

Red Hat provides supported .NET container images and OpenShift guidance for .NET applications. For example, Red Hat's documentation describes dotnet SDK images and corresponding runtime/ASP.NET runtime image streams for OpenShift. (Red Hat Documentation)

That means an enterprise can standardize on:

.NET
+
Red Hat Enterprise Linux/UBI-based containers
+
OpenShift
+
Azure

For example:

.NET 10
   ↓
ASP.NET Core
   ↓
Red Hat UBI-based container
   ↓
OpenShift
   ↓
Azure Red Hat OpenShift

Red Hat's current documentation includes guidance for running .NET 10 on OpenShift and provides dotnet, dotnet-runtime, and dotnet-aspnet image streams. (Red Hat Documentation)


29. CI/CD Pipeline

A typical enterprise pipeline might look like:

Developer
    |
    ↓
Git Repository
    |
    ↓
CI Pipeline
    |
    +-- Build
    +-- Unit Tests
    +-- SonarQube
    +-- Security Scan
    +-- Docker Build
    |
    ↓
Container Registry
    |
    ↓
CD Pipeline
    |
    ↓
ARO
    |
    ↓
OpenShift Deployment
    |
    ↓
Pods

For example:

docker build -t orderservice:1.0 .
docker push myregistry.azurecr.io/orderservice:1.0

oc apply -f deployment.yaml

In a real enterprise pipeline, image tags would normally be immutable version/build identifiers rather than simply latest.


30. What Happens When a Pod Fails?

Suppose:

Order Service

Pod 1 → Running
Pod 2 → Running
Pod 3 → Failed

The desired state says:

replicas = 3

The orchestration layer can create another Pod:

Pod 1 → Running
Pod 2 → Running
Pod 3 → Failed
Pod 4 → Starting

Eventually:

Pod 1 → Running
Pod 2 → Running
Pod 4 → Running

The application therefore doesn't have to manually detect and recreate failed instances.


31. Production Architecture

A mature enterprise architecture could look like:

                    Internet
                       |
                       ↓
                Azure Front Door
                       |
                       ↓
              WAF / Load Balancing
                       |
                       ↓
              Azure Red Hat OpenShift
                       |
        +--------------+--------------+
        |              |              |
        ↓              ↓              ↓
   API Gateway      Services       Workers
        |              |              |
        |        +-----+-----+        |
        |        |     |     |        |
        ↓        ↓     ↓     ↓        ↓
     Orders   Payment Inventory Customer
        |
        ↓
  Azure Service Bus
        |
        ↓
 Notification Worker
        |
        ↓
 External Systems

Supporting services:

Azure SQL
Azure Cache for Redis
Azure Key Vault
Azure Container Registry
Application monitoring
Centralized logging
CI/CD

32. Is ARO Mandatory in Microservices?

Again:

❌ No.

Microservices can run on:

AKS
ARO
Azure Container Apps
Docker Compose
ECS
GKE
Self-managed Kubernetes
Virtual Machines
Other container platforms

The correct architecture decision is:

Business Requirements
        ↓
Non-functional Requirements
        ↓
Platform Requirements
        ↓
Choose Hosting Platform

Not:

.NET
 ↓
Must use ARO ❌

33. When Should You Choose ARO?

Choose ARO when your organization needs things such as:

Enterprise OpenShift standardization

Your company already uses OpenShift across environments.

Kubernetes + OpenShift ecosystem

You need OpenShift-specific platform capabilities and workflows.

Managed Azure deployment

You want OpenShift deployed into Azure while Microsoft and Red Hat handle important platform operations. (Microsoft Learn)

Large microservices platform

You have many containerized services and need centralized orchestration.

Hybrid-cloud consistency

You want an OpenShift-based application platform that can fit into broader hybrid-cloud strategies.

Enterprise security/governance

You need platform-level identity, RBAC, networking, policy, and operational controls.


34. When Should You NOT Choose ARO?

If you have:

One ASP.NET Core API

and your requirement is simply:

Host the API

ARO could be unnecessary complexity.

You might choose:

Azure App Service

instead.

Likewise, if your team already has strong Azure Kubernetes expertise and doesn't need OpenShift, AKS may be a more natural choice.


35. ARO Interview Question

Q: Is Azure Red Hat OpenShift mandatory for .NET Core?

Answer:

No. Azure Red Hat OpenShift is not mandatory for .NET Core applications. .NET applications can run on Azure App Service, Azure Container Apps, AKS, virtual machines, Docker, and other platforms. ARO is a managed OpenShift platform on Azure and is mainly selected when an organization needs enterprise OpenShift/Kubernetes capabilities, OpenShift standardization, hybrid-cloud consistency, or specific operational and governance requirements.

That's the answer I'd recommend giving in a .NET Architect interview.


36. The Most Important Concept

Remember this hierarchy:

             .NET
              │
              │ builds
              ↓
        ASP.NET Core API
              │
              │ packaged as
              ↓
          Docker Image
              │
              │ deployed to
              ↓
          OpenShift
              │
              │ hosted on
              ↓
       Azure Red Hat OpenShift
              │
              ↓
           Azure

ARO is the hosting/orchestration platform—not a requirement of the .NET framework.


37. Final Summary

Azure Red Hat OpenShift combines Azure + Red Hat OpenShift + Kubernetes-based container orchestration + managed platform operations. Microsoft says ARO provides fully managed OpenShift clusters, with Microsoft and Red Hat jointly engineering, operating, and supporting the service. (Microsoft Learn)

For a .NET microservices application:

.NET Microservice
       ↓
Docker Container
       ↓
Container Registry
       ↓
Azure Red Hat OpenShift
       ↓
OpenShift Deployment
       ↓
Pods
       ↓
Service
       ↓
Route
       ↓
Users

The key takeaway is:

Don't choose ARO because you use .NET. Choose ARO when your application's operational, architectural, enterprise, or organizational requirements justify an OpenShift platform.

Official references

Azure Red Hat OpenShift — Microsoft Learn

Azure Red Hat OpenShift documentation

.NET on OpenShift — Red Hat documentation

Create an Azure Red Hat OpenShift cluster

If you're publishing this as a blog, a strong title would be “Azure Red Hat OpenShift (ARO) with .NET 10: Complete Guide to Deploying ASP.NET Core Microservices with Real-Time E-Commerce Example”.

Don't Copy

Protected by Copyscape Online Plagiarism Checker