From AKS to ACA: Securing Private Azure Container Apps with Application Gateway and Bicep Automation

May 21, 2025 • Don Santmajor

From AKS to ACA: Securing Private Azure Container Apps with Application Gateway and Bicep Automation

Categories: Azure CloudNative DigitalTransformation AzureContainerApps ApplicationGateway Bicep InfrastructureAsCode Devsecops

Tags: Azure CloudNative DigitalTransformation AzureContainerApps ApplicationGateway Bicep InfrastructureAsCode Devsecops

From AKS to ACA: Securing Private Azure Container Apps with Application Gateway and Bicep Automation

As enterprise architects and cloud consultants, our work often revolves around bridging the gap between strategic business objectives and robust technical implementations. A recent engagement with a client, undergoing significant digital transformation, perfectly illustrates this. Their challenge was a common one: how to securely expose private microservices, initially built on Azure Kubernetes Service (AKS), in a scalable and manageable way, ultimately aiming for the simplified operational model of Azure Container Apps.

From an Enterprise Architecture perspective, guided by principles like TOGAF, our goal was clear: establish a secure, performant, and highly automated application layer. This meant ensuring stringent security controls at the perimeter while providing seamless, reliable access to internal, privately deployed applications. The transition to Azure Container Apps was driven by a business case focused on reducing operational overhead and letting development teams focus on core business logic, embracing a serverless Kubernetes paradigm.

This blog post will delve into the technical solution: leveraging Azure Application Gateway to protect private Azure Container Apps, and crucially, how we achieved highly repeatable and user-friendly deployments using Bicep loops.


The Architecture: Private Container Apps, Public Gateway

The core architectural pattern involved deploying Azure Container Apps exclusively within a private Azure Virtual Network (VNet). This ensures they are not directly accessible from the public internet, significantly reducing their attack surface. To provide controlled public access, we positioned an Azure Application Gateway in a dedicated subnet within the same VNet.

alt text

Here’s the logical flow:

  1. External Request: A user’s request (e.g., clientA.companyAsolutions.com) hits the Application Gateway’s public IP address.
  2. Application Gateway Processing:
    • SSL Termination: The Application Gateway handles SSL termination for the custom domain.
    • WAF Inspection: The Web Application Firewall (WAF) inspects the request for common web vulnerabilities (e.g., SQL injection, XSS) before forwarding it.
    • Host-Based Routing: Based on the incoming hostname (e.g., clientA.companyAsolutions.com), the Application Gateway routes the traffic.
  3. Internal Routing: The request is forwarded to the correct, private Azure Container App using its internal FQDN (e.g., internal.mydomain.org as seen in our Bicep parameters, typically resolved via Private DNS Zones).
  4. Container App Response: The Container App processes the request and sends the response back through the Application Gateway to the user.

This pattern provides:


The Automation: Bicep Loops for Dynamic Configuration

The real challenge in managing such an architecture, especially for a client with numerous microservices, is maintaining consistency and reducing manual effort. This is where Bicep and its powerful looping constructs became indispensable.

Instead of writing repetitive code for each microservice’s configuration on the Application Gateway, we parameterized the solution using an array of objects. Each object in this array represents a distinct microservice (or Container App) and its specific requirements:

       "containerApps": { 
         "type": "Array", 
         "value": [ 
           { 
             "certName": "clientA-cert", 
             "customDomainName": "internal.mydomain.org", // Represents the internal FQDN of the Container App
             "fqdn": "clientA.companyAsolutions.com",     // Public FQDN exposed via AGW
             "name": "clientA", 
             "probeHost": "clientA.companyAsolutions.com", // Host header for AGW health probes
             "timeoutSeconds": 30 
           }, 
           { 
             "certName": "clientB-cert", 
             "customDomainName": "internal.mydomain.org", 
             "fqdn": "clientB.companyAsolutions.com", 
             "name": "clientB", 
             "probeHost": "clientB.companyAsolutions.com", 
             "timeoutSeconds": 30 
           } 
         ] 
       },

This containerApps array is the driving force behind our Bicep deployment. We then used Bicep’s for loops to dynamically provision the required Application Gateway components for each entry in this array.

Here’s how the Bicep template leveraged these loops to automate what would otherwise be a tedious and error-prone manual configuration:

Dynamic Application Gateway Configuration with Bicep Loops

This looped approach dramatically simplifies the Bicep template. Adding a new microservice to be exposed merely involves extending the containerApps parameter array, not writing dozens of lines of redundant Bicep code. This aligns perfectly with DevOps principles of automation and repeatability.


Application Gateway WAF: Best Practices for Robust Security

Beyond basic routing, the Application Gateway’s integrated Web Application Firewall (WAF) is a critical component for protecting web applications. For this solution, we implemented WAF in Prevention mode, leveraging the latest CRS (Core Rule Set) version. This is non-negotiable for enterprise-grade security.

Here are the Key WAF Best Practices we applied:

This comprehensive WAF configuration provides a strong first line of defense, mitigating common web attacks before they even reach the private Container Apps.


It’s important for seasoned practitioners to acknowledge that while Azure Container Apps offers significant benefits in terms of developer experience and operational simplicity compared to AKS, it does have known limitations in certain advanced, configMap, networking or traffic management scenarios. For instance, highly complex path-based routing, configMap features might be more straightforward in a full AKS environment.

However, our approach effectively worked around these limitations by offloading much of that complexity to the robust and feature-rich Azure Application Gateway. This allowed us to:

This demonstrates that by strategically combining Azure services, we can achieve enterprise-grade capabilities even when individual platform features might have specific constraints. It’s about understanding the platform’s capabilities and knowing how to build a complete, resilient solution.


Conclusion: A Blueprint for Cloud-Native Enterprise Adoption

This architectural blueprint, automated with Bicep loops, offers a powerful solution for organizations adopting Azure Container Apps for their microservices architecture. It provides the necessary security, scalability, and operational efficiency critical for digital transformation initiatives.

For our client, it meant shedding the overhead of self-managed Kubernetes and gaining valuable engineering focus. For us, it’s another example of how mialdo.com delivers tangible, high-impact cloud solutions that align technology with core business objectives. This pattern ensures that while the Container Apps remain agile and focused on application logic, the ingress and security layers are robust, centralized, and automated.

If your organization is navigating similar cloud migrations or looking to refine your Azure architecture, mialdo.com brings the field experience to turn these complexities into streamlined, secure, and performant realities.


#Azure #CloudNative #DigitalTransformation #AzureContainerApps #ApplicationGateway #Bicep #InfrastructureAsCode #CloudSecurity #Microservices #Serverless #EnterpriseArchitecture #MialdoSolutions #CloudConsulting #AzureArchitecture #DevOps #CloudMigration #ITTransformation #CloudStrategist #AzureExpert #WAF #MicrosoftEntraID #RBAC #CloudIdentity #NetworkSecurity