Volume 8 · Chapter 9 — Azure Cloud Architecture & Enterprise DevOps for .NET Engineers
Cloud Security and Governance
9.1 Introduction
In the cloud, identity is the new perimeter. With services reachable over the network and infrastructure defined in software, security shifts from firewalls at the edge to who and what can access each resource, enforced by identity, least privilege, and policy. Governance ensures those controls are applied consistently across a sprawling estate. For a bank, this is existential: a single misconfigured identity or exposed secret can breach regulatory obligations and customer trust.
9.2 Identity as the Foundation
Microsoft Entra ID is the identity backbone: it authenticates users, applications, and services and authorizes their access via RBAC. The principles are strong authentication (MFA, conditional access), least privilege (grant only what is needed), and continuous verification (Zero Trust - never trust based on network location alone).
flowchart TB User["User / Service"] --> Entra["Entra ID\n(authN + conditional access + MFA)"] Entra --> RBAC["RBAC (authZ)\nleast-privilege role assignment"] RBAC --> Res["Azure Resource"] MI["Managed Identity"] --> Entra KV["Key Vault (secrets/keys/certs)"] --> Res
9.3 RBAC and Least Privilege
Role-Based Access Control grants permissions through roles scoped to a management group, subscription, resource group, or resource. Least privilege means assigning the narrowest role at the narrowest scope - a Reader on one resource group, not Owner on a subscription. Custom roles refine this further, and Privileged Identity Management provides just-in-time, time-bound elevation for administrative access so standing privilege is minimized.
9.4 Managed Identities - Eliminating Secrets
The most impactful security practice is removing stored credentials. Managed identities give an Azure resource an Entra identity so it authenticates to other services (SQL, Storage, Key Vault) with automatically rotated platform tokens and no secret in code or config. This closes off the most common breach vector - leaked connection strings and keys.
// No secrets anywhere: the app's managed identity authenticates to Key Vault,
// which in turn holds any unavoidable third-party secrets.
var cred = new DefaultAzureCredential();
var secrets = new SecretClient(new Uri("https://bank-kv.vault.azure.net/"), cred);
string apiKey = (await secrets.GetSecretAsync("partner-api-key")).Value.Value;
9.5 Azure Key Vault
Key Vault centrally stores secrets, encryption keys, and certificates with access controlled by Entra RBAC, full audit logging, and optional HSM backing. Applications retrieve what they need at runtime via managed identity, secrets are rotated centrally, and nothing sensitive is embedded in code, config, or images.
9.6 Network Security and Defense in Depth
Identity is layered with network controls (Chapter 3): NSGs, private endpoints, Azure Firewall, and Web Application Firewall. Defense in depth means no single control is the only barrier - a compromised credential still faces network segmentation, and a network breach still faces identity checks.
9.7 Microsoft Defender for Cloud and Sentinel
Defender for Cloud continuously assesses security posture, scores it, surfaces misconfigurations and vulnerabilities, and provides workload threat protection. Microsoft Sentinel is the cloud-native SIEM that aggregates signals across the estate for threat detection and response. Together they turn security from a point-in-time review into continuous monitoring.
9.8 Azure Policy and Governance
Azure Policy enforces rules automatically across resources - allowed regions, required tags, mandated encryption or private endpoints, denied public IPs - either blocking non-compliant deployments or remediating them. Combined with a landing-zone hierarchy and cost governance (budgets, alerts, right-sizing), it keeps a large estate compliant and cost-controlled without manual policing.
How do you secure Azure applications end to end?
I build defense in depth anchored on identity. Access is identity-based through Entra ID with MFA and conditional access, authorized by least-privilege RBAC scoped as narrowly as possible, with just-in-time elevation for admin roles. Applications use managed identities so there are no stored credentials, and any unavoidable secrets live in Key Vault, retrieved at runtime and centrally rotated. The network layer adds NSGs, private endpoints (keeping PaaS off the internet), and WAF/firewall, so a compromised credential still meets segmentation and vice versa. Data is encrypted at rest and in transit. Continuous monitoring via Defender for Cloud and Sentinel detects misconfiguration and threats, and Azure Policy enforces security baselines automatically. No single control is the whole defense - the layers combine so that breaching one does not breach the system.
What is Zero Trust and how does it apply in Azure?
Zero Trust replaces the old “trusted internal network” assumption with “never trust, always verify”: every access request is authenticated, authorized, and validated regardless of where it originates. In Azure that means verifying identity explicitly on every request (Entra ID with MFA and conditional access evaluating user, device, location, and risk), enforcing least-privilege access (narrow RBAC, just-in-time elevation via PIM), and assuming breach (segment networks, use private endpoints, encrypt everything, monitor continuously so a compromised credential or host has limited reach). Practically, it is why we do not rely on network location for trust - a request from inside the VNet still must prove identity and authorization. Zero Trust is the mindset that ties identity, least privilege, segmentation, and monitoring into one coherent posture.
Why should secrets never be stored in application configuration or code?
Because config files and code get committed to source control, copied into build artifacts and container images, printed in logs, and shared across environments - each a path for a secret to leak, after which it is hard to know it is compromised or to rotate it without breaking things. The modern answer is to avoid stored secrets almost entirely: use managed identities so services authenticate with platform-rotated tokens and no secret exists, and for unavoidable third-party secrets store them in Key Vault and fetch them at runtime via that identity, with central rotation and audit. This removes the most common breach vector - leaked connection strings and keys - and gives least-privilege, auditable, rotatable access instead of static credentials scattered through the codebase.
How do you design security governance for a large regulated enterprise on Azure?
I make security a property of the platform, enforced automatically, not a per-team afterthought. It starts with a landing zone: a management-group hierarchy where security and compliance policies cascade down, subscriptions separating production and non-production for blast-radius and access isolation, and centralized identity. Azure Policy enforces non-negotiable guardrails - allowed regions, mandatory encryption and private endpoints, required tags, denied public exposure - so non-compliant resources are blocked or auto-remediated regardless of what teams deploy. Identity is Zero Trust: Entra ID with conditional access and MFA, least-privilege RBAC, and PIM for just-in-time admin. Golden IaC modules make the compliant configuration the default, and pipelines enforce IaC and image scanning. Continuous monitoring (Defender for Cloud posture scoring, Sentinel SIEM) plus centralized logging give visibility and audit evidence for regulators. Cost governance runs alongside with budgets and policy. The model is centralized guardrails and continuous enforcement, so thousands of resources stay compliant without manual policing, while teams self-serve within the rails.
A security review finds several teams have over-privileged service principals and standing Owner roles. How do you remediate at scale?
Over-privilege is a systemic problem, so I fix the system, not just the instances. First I gain visibility - use Entra access reviews and tooling to inventory who and what has which roles at which scopes, and identify the excess (Owner where Contributor or a custom role would do, subscription-scope where resource-group scope suffices, standing admin that should be just-in-time). Then I remediate in waves: replace standing privileged roles with Privileged Identity Management so elevation is time-bound and approved, right-size assignments to least privilege at the narrowest scope, and replace over-broad service principals with managed identities holding narrowly scoped data roles. Crucially I prevent recurrence: enforce least-privilege patterns through golden IaC modules and policy, require access to be granted via reviewed IaC rather than ad hoc portal clicks, and schedule recurring access reviews so entitlements are re-justified periodically and stale grants expire. I also add alerting on high-privilege role assignments. The combination of cleanup plus JIT, IaC-enforced least privilege, and periodic reviews turns a one-time finding into a durable control.
9.9 Banking Enterprise Scenario
A bank secures its Azure estate on a Zero Trust foundation. Access is through Entra ID with MFA and conditional access, authorized by least-privilege RBAC, and admin roles are granted just-in-time via Privileged Identity Management. Every application uses managed identities - no connection strings anywhere - and the few unavoidable third-party secrets live in Key Vault, retrieved at runtime and centrally rotated. Network defense in depth (private endpoints, NSGs, WAF) layers on top, and data is encrypted throughout. Azure Policy enforces allowed regions, mandatory encryption, and required private endpoints across every subscription, while Defender for Cloud and Sentinel provide continuous posture management and threat detection with the audit trail regulators require. Governance is centralized in the landing zone, so the controls hold uniformly as the estate grows.
Chapter Revision Notes
- Identity is the cloud perimeter - anchor security on Entra ID and least privilege.
- Adopt Zero Trust: verify explicitly, least privilege, assume breach.
- Use managed identities to eliminate stored secrets; Key Vault for the rest.
- Layer identity with network controls for defense in depth.
- Enforce guardrails automatically with Azure Policy; monitor with Defender/Sentinel.
- Centralize governance in a landing zone so controls scale with the estate.