Visualize Azure resources, dependencies, and infrastructure architecture with diagrams and documentation tools
This skill helps you create visual representations of Azure infrastructure, map resource dependencies, and generate architecture diagrams.
Use this skill when you need to:
az login)# List all resources
az resource list --resource-group myResourceGroup --output table
# Get detailed resource information
az resource list --resource-group myResourceGroup --output json > resources.json
# Get resources and create a basic diagram
az resource list --resource-group myResourceGroup --query "[].{name:name, type:type}" -o json
Three-Tier Web Application:
graph TB
subgraph "Azure Resource Group: Production"
LB[Azure Load Balancer<br/>Traffic Distribution]
AS[App Service<br/>Web Application]
APPI[Application Insights<br/>Monitoring]
KV[Key Vault<br/>Secrets Management]
SQL[Azure SQL Database<br/>Data Storage]
STORAGE[Storage Account<br/>Blob Storage]
REDIS[Azure Cache for Redis<br/>Caching Layer]
end
LB -->|routes traffic| AS
AS -->|logs telemetry| APPI
AS -->|reads secrets| KV
AS -->|queries data| SQL
AS -->|cache layer| REDIS
AS -->|stores files| STORAGE
SQL -->|automated backup| STORAGE
Microservices Architecture:
graph LR
subgraph "Frontend"
APIM[API Management<br/>Gateway]
end
subgraph "Services"
SVC1[Container App 1<br/>Order Service]
SVC2[Container App 2<br/>Inventory Service]
SVC3[Container App 3<br/>Payment Service]
end
subgraph "Data"
COSMOS[Cosmos DB<br/>NoSQL Database]
SQLDB[Azure SQL<br/>Relational DB]
EVENTHUB[Event Hub<br/>Event Streaming]
end
APIM --> SVC1
APIM --> SVC2
APIM --> SVC3
SVC1 --> COSMOS
SVC2 --> SQLDB
SVC3 --> EVENTHUB
# Analyze and visualize Azure resources
param(
[Parameter(Mandatory=$true)]
[string]$ResourceGroupName
)
# Get all resources
$resources = az resource list --resource-group $ResourceGroupName | ConvertFrom-Json
Write-Host "# Azure Resource Group: $ResourceGroupName"
Write-Host ""
Write-Host "```mermaid"
Write-Host "graph TB"
# Group resources by type
$resourcesByType = $resources | Group-Object -Property type
foreach ($group in $resourcesByType) {
$typeName = $group.Name.Split('/')[-1]
Write-Host " subgraph `"$typeName Resources`""
foreach ($resource in $group.Group) {
$safeName = $resource.name -replace '[^a-zA-Z0-9]', ''
Write-Host " $safeName[`"$($resource.name)`"]"
}
Write-Host " end"
}
Write-Host "```"
# Analyze dependencies
Write-Host ""
Write-Host "## Resource Dependencies"
Write-Host ""
foreach ($resource in $resources) {
$details = az resource show --ids $resource.id 2>$null | ConvertFrom-Json
if ($details.properties) {
Write-Host "### $($resource.name) ($($resource.type))"
# Check for common dependency patterns
$deps = @()
if ($details.properties.serverFarmId) {
$deps += "App Service Plan: $($details.properties.serverFarmId.Split('/')[-1])"
}
if ($details.properties.storageAccountId) {
$deps += "Storage Account: $($details.properties.storageAccountId.Split('/')[-1])"
}
if ($details.properties.subnet) {
$deps += "Subnet: $($details.properties.subnet.id.Split('/')[-1])"
}
if ($deps.Count -gt 0) {
foreach ($dep in $deps) {
Write-Host "- $dep"
}
}
Write-Host ""
}
}
const fs = require('fs');
function visualizeARMTemplate(templatePath) {
const template = JSON.parse(fs.readFileSync(templatePath, 'utf8'));
const resources = template.resources || [];
console.log('```mermaid');
console.log('graph TB');
console.log(' subgraph "ARM Template Resources"');
// Create nodes
resources.forEach((resource) => {
const name = resource.name.replace(/[\[\]'"\(\)]/g, '').replace(/[^a-zA-Z0-9]/g, '_');
const type = resource.type.split('/').pop();
console.log(` ${name}["${type}<br/>${resource.name}"]`);
});
console.log(' end');
// Create edges from dependsOn
resources.forEach((resource) => {
if (resource.dependsOn && Array.isArray(resource.dependsOn)) {
const sourceName = resource.name.replace(/[\[\]'"\(\)]/g, '').replace(/[^a-zA-Z0-9]/g, '_');
resource.dependsOn.forEach(dep => {
// Extract resource name from dependency string
const depMatch = dep.match(/\[.*?'([^']+)'/);
if (depMatch) {
const targetName = depMatch[1].replace(/[^a-zA-Z0-9]/g, '_');
console.log(` ${sourceName} -->|depends on| ${targetName}`);
}
});
}
});
console.log('```');
}
// Usage
if (process.argv.length < 3) {
console.error('Usage: node visualize.js <path-to-template.json>');
process.exit(1);
}
visualizeARMTemplate(process.argv[2]);
[Azure Front Door] -> [App Service]
|
+-> [Azure SQL Database]
+-> [Key Vault (Secrets)]
+-> [Application Insights]
+-> [Blob Storage]
[Event Grid] -> [Azure Functions]
|
+-> [Cosmos DB]
+-> [Service Bus]
+-> [Event Hub]
[Azure Container Registry] -> [Azure Kubernetes Service]
|
+-> [Service Mesh]
+-> [Azure Monitor]
+-> [Managed Databases]
Mermaid.js - Text-based diagrams (best for version control)
PlantUML - UML diagrams with Azure library
Draw.io (diagrams.net) - Visual editor
Azure Resource Graph - Query at scale
// Find all resources in a resource group
Resources
| where resourceGroup == "myResourceGroup"
| project name, type, location, tags
// Map dependencies between resources
Resources
| where resourceGroup == "myResourceGroup"
| extend dependencies = properties.dependsOn
| project name, type, dependencies
// Resources by location and type
Resources
| summarize count() by location, type
| order by count_ desc
# Export all resources with full details
az group export \
--name myResourceGroup \
--output json > infrastructure.json
# Query specific resource types
az resource list \
--resource-group myResourceGroup \
--resource-type "Microsoft.Web/sites" \
--output json
# Azure DevOps Pipeline