Deploy a Multi-Tier Application

By Pulumi Team
Published
Updated

The Challenge

You need to deploy a web application with clear separation between the presentation, application, and data layers. This three-tier pattern provides network isolation between tiers, independent scaling for each layer, and security boundaries that prevent direct access to your database from the internet.

What You'll Build

  • Three-tier architecture (web, API, database)
  • Virtual Network with subnet segmentation
  • Network security groups restricting inter-tier traffic
  • Azure SQL Database for relational data
  • Application Insights monitoring

Neo Try This Prompt in Pulumi Neo

Run this prompt in Neo to deploy your infrastructure, or edit it to customize.

Best For

Use this prompt when you need to deploy a web application with proper network segmentation and tier isolation on Azure. This pattern suits e-commerce applications, internal business tools, or any web application where the frontend, backend API, and database should scale and secure independently.

Architecture Overview

This architecture deploys a three-tier application on Azure with each tier running in its own subnet within a Virtual Network. The web tier uses Azure App Service to host the frontend, the application tier runs a containerized API in Azure Container Instances, and the data tier uses Azure SQL Database for relational storage. Network security groups enforce traffic flow rules: the web tier accepts public traffic, the API tier accepts traffic only from the web tier, and the database tier accepts connections only from the API tier.

This separation provides two benefits. First, it limits the blast radius of a security compromise. An attacker who gains access to the web tier cannot directly reach the database because network rules block that path. Second, it allows each tier to scale independently. You can scale the web frontend without changing the API or database configuration, and vice versa.

Application Insights provides monitoring across all three tiers. It collects request metrics, exception telemetry, and dependency call information, giving you end-to-end visibility into how requests flow from the frontend through the API to the database. This is essential for diagnosing performance issues in a multi-tier architecture where latency can originate in any layer.

Web Tier

Azure App Service hosts the frontend application and handles TLS termination, load balancing, and scaling. It is deployed into the web subnet, which is the only subnet with a network security group rule allowing inbound traffic from the internet. App Service provides built-in deployment slots for staging changes before they reach production.

Application Tier

Azure Container Instances run the backend API in the application subnet. Container Instances are a good fit for APIs that need custom runtime environments or dependencies packaged in a container image. The API connects to the SQL Database in the data subnet and exposes endpoints that only the web tier can reach.

Data Tier

Azure SQL Database provides a managed relational database in the data subnet. It handles backups, patching, and high-availability replication. The network security group on the data subnet restricts inbound connections to the application subnet, ensuring the database is never directly accessible from the web tier or the internet.

Common Customizations

  • Add a Redis cache: Extend the prompt to include Azure Cache for Redis between the API and database tiers to reduce database load for frequently accessed data.
  • Enable autoscaling: Ask for App Service autoscaling rules based on request count or CPU utilization to handle traffic spikes without manual intervention.
  • Add a staging environment: Request deployment slots on App Service so you can deploy and validate changes before swapping them into production.
  • Use Private Endpoints: Ask for Azure Private Endpoints on the SQL Database to route traffic over the Azure backbone network instead of through the public internet.