Azure architecture diagrams are essential for documenting cloud infrastructure, but maintaining them is often a nightmare. Traditional diagramming tools produce static images that go stale the moment your infrastructure changes.
Mermaid changes this. It's a diagramming tool that uses code (Markdown-like syntax) to generate diagrams, making them version-controllable, reviewable, and automatable. When you combine Mermaid with Azure, you get architecture diagrams that live alongside your infrastructure code and evolve with it.
This guide covers everything you need to know about creating Azure architecture diagrams with Mermaid—the syntax, real examples, best practices, and the tools that make it work.
Cloud Architecture
Create cloud architecture diagrams for AWS, Azure, GCP, and more. Design scalable infrastructure with professional cloud icons.
Complete guide to Mermaid Azure architecture diagrams—flowchart vs architecture-beta syntax, Azure icons, examples, automation, and best practices.
Click Cloud Architecture to open AI Line Studio and generate diagrams from natural language in seconds.
Mermaid turns plain text into diagrams. This matters for cloud architecture because:
Version control works. Mermaid diagrams are text files. You can check them into Git, track changes, review them in pull requests, and diff them like code. No more binary PNG files with unreadable diffs.
Documentation stays in sync. When your infrastructure-as-code changes, your diagrams can change in the same pull request. The diagram lives alongside the code it documents.
No vendor lock-in. Mermaid renders in GitHub, GitLab, VS Code, Notion, Confluence, and most Markdown renderers. Your diagrams work everywhere.
Automation is possible. You can generate Mermaid diagrams from Terraform state, Azure resource groups, or Bicep templates. Microsoft's azure-resource-visualizer skill does exactly this—analyzing deployed Azure resource groups and generating detailed Mermaid architecture diagrams.
Mermaid supports two primary syntaxes for architecture diagrams. Understanding both is essential.
graph TB / graph LR)This is the classic Mermaid approach. You define nodes and edges, and Mermaid handles the layout. It's simple, widely supported, and works in virtually every Mermaid environment.
Use graph TB (top-to-bottom) for vertical layouts. This is common for layered architectures where you want to show tiers from top to bottom.
Use graph LR (left-to-right) for horizontal layouts. This works better for wide architectures with many components across multiple layers.
architecture-beta)Mermaid v11.1.0+ introduced a dedicated architecture-beta syntax for cloud architecture diagrams. This syntax is specifically designed for infrastructure visualization.
Key difference: Architecture syntax supports grouping and relationships between services in a more structured way. However, it's still beta—not all services are supported, and layout consistency can vary.
Official example:
architecture-beta
group api(cloud)[API]
service db(database)[Database] in api
service disk1(disk)[Storage] in api
service disk2(disk)[Storage] in api
service server(server)[Server] in api
db:L -- R:server
disk1:T -- B:server
disk2:T -- B:db
Important limitation: Mermaid's default icon set for architecture diagrams is limited to five icons: cloud, database, disk, internet, and server. For Azure-specific icons, you need to register custom icon packs.
This real example from Microsoft's Azure Verified Modules shows a comprehensive Azure AI Foundry deployment:
graph TB
subgraph "Core AI Foundry (Required)"
Account[AI Foundry Account]
Project[Projects]
Agent[Agent Service]
Connections[Connections]
end
subgraph "BYOR Services (Optional)"
KV[Key Vault]
Storage[Storage Account]
Cosmos[Cosmos DB]
Search[AI Search]
end
subgraph "Supporting Services"
Logs[Log Analytics Workspace]
Roles[Role Assignments]
Locks[Resource Locks]
end
subgraph "Networking (Private Deployment)"
VNet[Virtual Network]
Subnets[Subnets]
DNS[Private DNS Zones]
Endpoints[Private Endpoints]
Bastion[Bastion]
VMs[Virtual Machines]
end
What this diagram shows:
Hub-spoke is the foundational Azure networking pattern. The mermaid-azure VS Code extension can generate this directly from prompts:
graph LR
subgraph "Hub VNet"
FW[Azure Firewall]
VPN[VPN Gateway]
Bastion[Azure Bastion]
end
subgraph "Spoke 1"
VM1[Virtual Machines]
Subnet1[Subnet]
end
subgraph "Spoke 2"
VM2[Virtual Machines]
Subnet2[Subnet]
end
FW --> VM1
FW --> VM2
VPN --> FW
Microsoft's Azure Resource Visualizer skill generates Mermaid diagrams showing resource relationships within an Azure resource group:
graph TB
subgraph "Resource Group: [name]"
subgraph "Network"
VNet[Virtual Network]
Subnet[Subnet]
NSG[Network Security Group]
end
subgraph "Compute"
VM[Virtual Machine]
NIC[Network Interface]
end
subgraph "Data"
Storage[Storage Account]
SQL[SQL Database]
end
subgraph "Security"
KV[Key Vault]
end
end
Key principles from this example:
This example uses the Azure icon pack with native Azure service icons:
graph TB
subgraph "Hub VNet"
FW[azure:firewalls]
LB[azure:load-balancers]
GW[azure:virtual-network-gateways]
end
Note: This syntax requires registering the Azure icon pack. The @f5xc-salesdemos/icons-azure pack provides native Azure service icons for Mermaid diagrams.
Mermaid doesn't include Azure icons by default. You need to register them.
In Mermaid v11+, you can register custom icon packs:
window["mermaid"].registerIconPacks([
{
name: "azure",
loader: () => fetch("https://unpkg.com/azureiconkento@1.1.1/azureicons/allicons.json")
.then((response) => response.json())
}
]);
This example loads the azureiconkento icon pack. Once registered, you can use azure: prefix in your diagrams:
architecture-beta
service vm(azure:virtual-machine)[VM]
service sql(azure:sql-database)[SQL DB]
The mermaid-azure VS Code extension provides Azure architecture diagram support with built-in Azure icons. It offers three commands:
Several community icon packs support Azure icons for Mermaid:
@f5xc-salesdemos/icons-azure — native Azure service icons (firewalls, load balancers, virtual network gateways, etc.)| Tool | Purpose | Key Feature |
|---|---|---|
| mermaid-azure (VS Code) | Azure diagram generation | Hub-spoke, subscriptions, resource groups |
| Azure Resource Visualizer | Auto-generate from live Azure | Analyzes resource groups |
| Mermaid Live Editor | Online rendering | Preview and edit |
| Markdown Preview Enhanced | VS Code preview | Custom icon packs |
| GitHub Copilot for Azure | AI-assisted generation | Creates diagrams from prompts |
This extension provides Azure architecture diagram support directly in VS Code:
Features:
Usage:
Example prompt: "Hub-spoke configuration with a firewall in the hub and two spokes with VMs"
Microsoft's azure-resource-visualizer skill analyzes deployed Azure resource groups and generates detailed Mermaid architecture diagrams.
When to use it: When you need to visualize existing Azure resources or understand how resources relate to each other.
What it produces: Comprehensive Mermaid diagrams that clearly illustrate the architecture.
Syntax requirements:
graph TB (top-to-bottom) or graph LR (left-to-right)Subgraphs (subgraph "Name" ... end) are the primary way to organize resources by function, layer, or environment.
Common groupings:
Use graph TB (top-down) for:
Use graph LR (left-right) for:
Each node should have a clear, descriptive label:
VM[Virtual Machine - Web Server]
SQL[Azure SQL Database - Customer Data]
KV[Azure Key Vault - Secrets]
Edges show how data flows between components:
WebApp --> SQL[Azure SQL Database]
WebApp --> Cache[Azure Redis Cache]
API --> ServiceBus[Azure Service Bus]
When using Mermaid diagrams in documentation, include:
Mermaid supports styling nodes with different colors:
style VNet fill:#0072C6,stroke:#005A9E,color:#FFFFFF
style SQL fill:#0072C6,stroke:#005A9E,color:#FFFFFF
style VM fill:#F25022,stroke:#C7502A,color:#FFFFFF
Don't overload one diagram. If it has more than 20-30 nodes, break it into multiple diagrams at different abstraction levels.
Use separate diagrams for:
The real power of Mermaid Azure diagrams comes from automation. Several tools can generate diagrams automatically:
The azure-resource-visualizer skill analyzes deployed Azure resource groups and generates comprehensive Mermaid diagrams:
The generate-terraform-module-diagram skill analyzes Terraform modules and generates Mermaid diagrams with embedded Azure and AWS provider icons.
The mermaid-azure VS Code extension can use Bicep file context to generate architecture diagrams.
GitHub Copilot for Azure can create Mermaid architecture diagrams directly from natural language prompts.
Mermaid diagrams integrate seamlessly with modern documentation workflows:
GitHub and GitLab: Mermaid renders natively in Markdown files. Diagrams appear directly in READMEs and wikis.
VS Code: Mermaid preview is built in or available via extensions like Markdown Preview Enhanced.
Azure DevOps Wikis: Mermaid renders in Azure DevOps wiki pages.
CI/CD Automation: The azure-resource-visualizer skill is part of Microsoft's azure-skills repository, enabling automated diagram generation in CI/CD pipelines.
| Pitfall | Solution |
|---|---|
| Icons don't render | Register Azure icon packs in your Mermaid configuration |
| Layout changes on save | Beta syntax is still evolving—use stable flowchart syntax for production |
| Complex diagrams are messy | Break into multiple smaller diagrams; use subgraphs for grouping |
| Mermaid syntax errors | Test in Mermaid Live Editor before committing |
| No Azure icons in GitHub | GitHub doesn't support custom icon packs—use text labels instead |
Mermaid Azure architecture diagrams bring the benefits of code-based documentation to cloud infrastructure:
Key takeaways:
| Aspect | Recommendation |
|---|---|
| Syntax | Use graph TB or graph LR for stability; architecture-beta for structured diagrams |
| Icons | Register Azure icon packs or use mermaid-azure extension |
| Grouping | Use subgraphs for logical organization (Network, Compute, Data, Security) |
| Tools | mermaid-azure (VS Code), Azure Resource Visualizer, Mermaid Live Editor |
| Automation | Generate from Terraform, Bicep, or live Azure resource groups |
| Documentation | Integrate with GitHub, Azure DevOps, and CI/CD pipelines |
The workflow that works:
If you're ready to move beyond static PNGs and start treating your Azure architecture diagrams as code, explore the Azure architecture diagram tool for editable visual alternatives, or try the AI cloud diagram generator to turn Azure descriptions into visual diagrams instantly. For complete system architecture beyond Mermaid, the AI system architecture generator covers distributed and enterprise system designs.