Volume 5 · Chapter 6 — Advanced .NET Cloud Native Architecture

CI/CD Enterprise Pipelines

Goutham Mayaluri 7 min read .NETC#CI/CDCloud Native

6.1 Introduction

CI/CD is the automation backbone of cloud-native delivery: Continuous Integration builds and validates every change; Continuous Delivery/Deployment promotes validated builds through environments to production. The goal is a pipeline where a commit flows to production through automated gates with no manual, error-prone steps - shrinking both the risk and the lead time of change. For containers, the pipeline builds and scans an image once and promotes that immutable artifact through to a Kubernetes deployment.

6.2 The Container CI/CD Pipeline

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant CI as CI (build, test, scan)
  participant ACR as Registry (ACR)
  participant Stg as Staging
  participant Prod as Production (gated)
  Dev->>CI: pull request / commit
  CI-->>Dev: build, unit tests, SAST, dependency + image scan
  CI->>ACR: push signed, versioned image
  ACR->>Stg: deploy + integration tests
  Stg->>Prod: approval / automated gate
  Prod-->>Dev: rolled out (canary -> full)

6.3 Pipelines as Code and Build-Once-Promote

Pipelines are defined as versioned YAML in the repository (Azure DevOps or GitHub Actions), giving version history, review, and repeatability. The container image is built and scannedonceand that same immutable image is promoted through staging to production - never rebuilt per environment, which invites drift. Configuration is injected at deploy time from Key Vault and App Configuration, not baked into the image.


// GitHub Actions / Azure DevOps (YAML, sketch): build once, scan, push, deploy.
//   - dotnet test -c Release
//   - docker build + trivy image scan (fail on critical CVEs)
//   - docker push acr.azurecr.io/payments-api:$SHA        # immutable, versioned
//   - kubectl set image / helm upgrade  (staging -> prod, gated)   # promote the same image

6.4 Deployment Strategies

Because most incidents are change-induced, how you deploy is a reliability control. Blue-green keeps two production environments and swaps traffic after validation (instant rollback). Canary exposes the new version to a small traffic slice while automated checks compare it to baseline before full rollout. Feature flags decouple deploying code from enabling behavior, allowing gradual rollout and instant kill switches without a redeploy.

6.5 Security in the Pipeline (Shift Left)

Security is integrated throughout, not added after: dependency (SCA) scanning, static analysis (SAST), secret scanning, container image scanning, and IaC scanning run on every pull request and gate merges. Pipelines authenticate to Azure and the cluster with workload identity / least-privilege service connections rather than stored credentials. (Volume 8 and 10 cover CI/CD and DevSecOps in depth.)

Senior Interview Question

Why treat pipelines as code, and why build an image once and promote it?

On pipelines as code: a delivery pipeline is critical infrastructure and deserves the same rigor as application code, so defining it as versioned YAML in the repository gives it version history (you can see who changed the build and why, and revert), code review (pipeline changes go through pull requests and branch policies), and reproducibility (the pipeline that built a past release is recorded alongside that code). It also enables reuse through templates, keeps the pipeline in sync with the code it builds since they evolve together, and removes the fragility and lack of auditability of click-configured pipelines. In short, pipeline-as-code turns the delivery process into a reviewed, versioned, repeatable asset rather than an opaque, manually-configured one. On build-once-promote: you build and test the container image a single time, then promote that exact same immutable image through staging to production, rather than rebuilding it for each environment - because rebuilding destroys the guarantee that what you tested is what you ship. Every build can differ subtly (a dependency version resolves differently, a base image updates, a timestamp changes), so a fresh build for production is technically a different, untested artifact even from identical source; that’s the source of “worked in staging, broke in prod” drift. Building once and promoting the same image means the exact bits you validated in CI and staging are the bits that go live, and only configuration - injected at deploy time from environment/Key Vault/App Configuration, never baked into the image - changes between environments. This also makes releases traceable to a specific, versioned image and enables reliable rollback to a known-good image. So the two principles together: pipeline-as-code makes the delivery process versioned, reviewed, and reproducible; build-once-promote makes the deployed artifact identical across environments so you ship exactly what you tested, varying only configuration. Both are foundational to reliable cloud-native delivery, and the anti-patterns they prevent - click-configured pipelines and per-environment rebuilds - are exactly what cause unauditable, drift-prone, hard-to-rollback deployments. The senior insight is that consistency and reproducibility of both the process (pipeline-as-code) and the artifact (build-once-promote) are what make automated delivery trustworthy.

Principal Engineer Question

How do you design a secure, reliable enterprise CI/CD platform for containerized services across many teams?

I build a paved road: shared, templated pipelines that encode the organization’s standards so every team inherits best practice by using the template rather than each reinventing (and mis-implementing) it. The templates handle the full flow for a containerized service - build, run tests with coverage, mandatory security scans (SAST, dependency/SCA, secret scanning, container image scanning, IaC scanning) that gate merges, build the image once, sign it, push it to a private registry (ACR), and deploy it by promoting that same immutable image through environments. Build-once-promote is enforced so what’s tested is what ships, with configuration injected at deploy time from Key Vault/App Configuration rather than baked into images. Security is shifted left and automated so vulnerabilities are caught on every pull request and can’t reach production, and images are scanned and signed with signature verification at deploy so only trusted images run - securing the supply chain. Governance lives in the platform: protected environments with required approvals for production, branch policies enforcing review and passing checks, and - crucially - pipelines authenticate to Azure and the cluster with workload identity / least-privilege service connections rather than stored credentials, so there are no long-lived secrets in the pipeline. Deployment strategies and rollback are built into the templates: readiness-gated rolling updates, canary or blue-green for risky changes with automated metric comparison and instant rollback, and feature flags to decouple deploy from release. For Kubernetes I’d support GitOps (Flux/ArgoCD) where the desired state lives in Git and a controller reconciles the cluster, giving auditable, declarative deployments. I keep pipelines fast (parallelism, caching, splitting fast PR checks from slower async suites) so the tight feedback loop that justifies CI is preserved and teams don’t batch risky changes. And I make it all observable - measuring DORA metrics (lead time, deployment frequency, change-fail rate, MTTR) - so I can see delivery health and improve. The platform team owns and continuously improves the templates and guardrails; application teams self-serve on the paved road, retaining autonomy over their service while inheriting the secure, consistent delivery process. So a secure, reliable enterprise CI/CD platform is: templated pipeline-as-code encoding standards, build-once-promote of immutable signed images with config injected at deploy, shift-left security scanning gating merges, least-privilege/workload-identity authentication with no stored secrets, protected environments with approvals, progressive delivery with rollback (canary/blue-green/flags, or GitOps for K8s), fast pipelines, and DORA-metric observability - delivered as a governed self-service paved road so many teams ship quickly and safely without each hand-rolling insecure, inconsistent pipelines. The unifying principle is centralized guardrails with team self-service: consistency, security, and reliability come from the shared platform, while teams move fast on top of it.

6.6 Banking Enterprise Scenario

A bank standardizes container delivery on templated pipelines. Every pull request builds, tests, and passes SAST, dependency, secret, and image scans before branch policies allow a merge. The main build produces a single versioned, signed image in ACR that is promoted unchanged through staging - where integration tests run - to production, a protected environment requiring approval. Production rollout is a canary on AKS with automated metric comparison and instant rollback, risky features hide behind flags, and pipelines authenticate with workload identity so no credentials are stored.

Chapter Revision Notes

  • Automate commit-to-production through gated pipelines to cut risk and lead time.
  • Define pipelines as versioned, reviewed YAML in the repo.
  • Build and scan the container image once; promote that immutable image; inject config at deploy time.
  • Use canary/blue-green and feature flags to de-risk change.
  • Shift security left (SAST/SCA/secret/image/IaC scans gating merges); authenticate with workload identity.