Emre Şahin

Arkitektura-kasuak

Azure Platform

Azure plataforma kode gisa. Produkzioa Azure Container Appsen, PostgreSQL pribatuarekin, Key Vaultekin eta identitate kudeatuekin, gehi on-prem k3s staging biki bat, dena OpenTofu eta Ansiblen definituta.

Rola
Cloud Architect
Aldia
2026
Teknologiak
Azure, OpenTofu, Ansible, Container Apps, Key Vault, k3s

Simplified and anonymised: no source code, customer data or confidential architecture details.

Overview & business problem

At Fortech we had several products, including BigiBuddy and Operliva, each with its own deployment habits. Some ran on a self-managed container cluster, some on hand-configured machines. Secrets lived in more places than anyone could list. There was no shared answer to "where does production run, and how do we rebuild it?"

The goal was one production platform for all products that a small team could afford and operate, private and identity-based by default, and described entirely in code. Alongside it we needed a development and staging environment that would not spend cloud budget on dozens of deployments a day.

My role & requirements

I owned the architecture and wrote most of the infrastructure as code. Product teams moved their services onto the platform, and pipelines were adopted repository by repository.

The requirements:

  • Everything reproducible from code and reviewed like code.
  • No database or internal service reachable from the public internet.
  • No long-lived passwords for registry or secret access.
  • Cost proportional to real usage, with sizing decisions written down.
  • A staging environment close enough to production to catch problems, without paying cloud prices for it.

Architecture & design decisions

The description here is simplified and is not the real production topology.

Production runs on Azure, defined with OpenTofu. Frontends are served as static web apps behind a CDN and web application firewall. APIs and workers run in an Azure Container Apps environment inside a virtual network, split into external apps (gateways and public pages), internal apps (APIs speaking HTTP/2 and gRPC), and workers that scale to zero when idle. Data lives in PostgreSQL Flexible Server with private networking only. Logs and metrics go to Log Analytics and Application Insights.

Container Apps over AKS. AKS was the familiar choice and the one most reference architectures recommend. It also means owning node pools, upgrades, ingress and add-ons, and paying for nodes whether they are busy or not. Container Apps bills per replica, scales to zero, and covers what our services need: internal and external ingress, HTTP/2 for gRPC, event-driven scaling, managed identity and Key Vault references. The services are plain containers, so moving later is a deployment change, not a rewrite.

Sizing as documented code. Every service is one entry in a map with CPU, memory, replica range and ingress, plus a comment explaining why. Authentication paths and public pages stay warm because a cold start there is visible to users. Heavy, rarely used workers scale to zero. A background worker that must not run twice is pinned to one replica, with the reason written next to it.

Identity instead of secrets. One user-assigned managed identity pulls images from the container registry and reads secrets from Key Vault. Secrets are referenced without a version, so rotation does not need a redeploy. The database administrator password is generated by the infrastructure code and written straight into Key Vault, so no person handles it.

An on-prem staging twin. We turned an existing office server into an isolated environment using Proxmox, OpenTofu and Ansible: a firewall VM as the only machine facing the office network, one VM per product, no open inbound ports, and access over a private overlay network only. A k3s cluster with an in-cluster registry runs the workloads, secrets are synced from the same Key Vault model, and an OpenTelemetry Collector feeds a Grafana-based observability stack.

One pipeline system, two environments. The same Azure DevOps definitions build every product. The develop branch runs on a self-hosted agent in the office and rolls out to k3s. The main branch runs on hosted agents, pushes to the container registry and deploys to Container Apps.

Trade-offs

Less control for less operations. Container Apps hides the cluster, which is the point, but a few settings must be patched outside the provider. At our scale, worth it.

A shared database server. Several product databases share one PostgreSQL server. It is a deliberate saving at our size, and splitting later is a data move rather than a redesign.

High availability as a variable. Zone-redundant database and geo-redundant backups are switches in code, off on the budget profile, with the cost trade-off documented next to them.

Staging is not production. k3s is not Container Apps, so scaling and cold-start behaviour only show up for real in production. We accepted that in exchange for free, fast staging deployments.

Security & scalability

PostgreSQL is VNet-integrated with private DNS and public access disabled. Backups and point-in-time restore are on, databases are protected against accidental deletion in code, and connection logging is enabled. Internal services are reachable only inside the environment. Infrastructure state lives in a restricted remote backend, because "no secrets in code" is not the same as "no secrets in state". The staging server exposes nothing to the office network beyond its firewall.

Scaling is per service, with explicit replica ranges; idle workers cost nothing.

Results & lessons learned

All products now have one production platform described in code, with private networking, identity-based access and point-in-time restore. Adding a service is a reviewed change to a map, not a ticket. Staging runs on hardware we already owned, so frequent deployments no longer cost cloud money.

There are honest gaps. The message broker currently runs as a container without durable storage, which is acceptable for now but not a final answer, and the code says so next to the resource.

What I'd do differently today

  • Start with a managed or durably stored message broker instead of planning to replace one later.
  • Add policy-as-code checks to the plan stage (public endpoints, unpinned images, plain-text secrets) so review is the second line of defence, not the first.
  • Schedule restore rehearsals from day one. Backups are only proven by restores.
  • Tag for per-product cost reporting from the first resource, so sizing decisions have a feedback loop.