如何将Azure配置导出为JSON模板并导入Visio构建环境架构图?
Got it, let's break down exactly how to pull off this Azure-to-Visio architecture mapping workflow—including time-point snapshots, multi-view templates, and metadata-driven organization. Here's a step-by-step approach that's worked for me and my team:
The goal here is to capture a frozen, timestamped snapshot of every Azure resource and its metadata.
Use Azure Resource Graph (ARG) for comprehensive resource data
ARG is the most efficient way to pull all resources across subscriptions. Run this Kusto query in the Azure Portal's ARG explorer to get core details:Resources | project ResourceName = name, ResourceType = type, ResourceGroup = resourceGroup, Location = location, Tags = tags, Properties = properties | order by ResourceGroup, ResourceTypeExport the results as a CSV or JSON file, and name it with a timestamp (e.g.,
azure-resources-snapshot-20240520.csv) to lock in the time-point reference.Supplement with network-specific details
For network-focused views, pull additional data using the Azure CLI:# Export VNet and subnets az network vnet subnet list --resource-group <your-rg> --vnet-name <your-vnet> --output json > vnet-subnets-snapshot-20240520.json # Export NSG rules az network nsg rule list --resource-group <your-rg> --nsg-name <your-nsg> --output json > nsg-rules-snapshot-20240520.jsonEnsure tags and metadata are included
Double-check that your export includes all custom tags (e.g.,BusinessUnit,Application,Environment)—these will be critical for organizing your Visio layouts later.
Visio has built-in tools to turn your exported data into a structured architecture diagram.
Semi-automate with Visio Data Visualizer
Open Visio, go to the Data tab, select Data Visualizer, and choose an Azure architecture template (e.g., "Azure Basic Network"). Import your CSV/JSON file, then map your exported fields to Visio shape properties:ResourceName→ Shape textResourceType→ Shape icon (Visio will auto-match many Azure resource types to its built-in icon set)ResourceGroup→ Container shape (to group resources by RG)Tags→ Shape data (for filtering later)
This will generate a basic, data-driven diagram in minutes.
Refine for precision
Auto-generated diagrams can be messy—take time to:- Rearrange shapes into logical groups (e.g., all web-tier VMs in one cluster)
- Add connections between dependent resources (e.g., VMs linked to their subnet, App Services linked to SQL DBs)
- Correct any mismatched icons (Visio might misclassify some custom resource types)
Create reusable templates to visualize your environment from different perspectives.
Use Visio Layers for view switching
Create dedicated layers for each perspective:Network Layer: VNet, subnets, NSGs, route tablesServer Layer: VMs, VM Scale Sets, hybrid serversApplication Layer: App Services, Functions, Logic AppsDatabase Layer: SQL DB, Cosmos DB, Redis Cache
To switch views, simply toggle layers on/off in the Layers panel.
Tag-driven business/application views
Use the tags you exported to filter shapes and build business-focused diagrams:- Go to the Data tab → Shape Data Filter
- Filter by a tag value (e.g.,
BusinessUnit = RetailorApplication = Checkout) - Save this filtered view as a separate template (
.vstxfile) for quick access later.
Save reusable master templates
Once you’ve finalized a view (e.g., network topology, server detail), save it as a Visio template. This lets you import new time-point snapshots and apply the same layout, icon mapping, and layer configuration in seconds.
Make your diagrams maintainable and actionable with metadata.
Standardize your tag schema
Ensure your Azure environment uses consistent tags (e.g.,BusinessUnit,ApplicationName,Environment,Tier)—this ensures your Visio shape data is uniform and easy to filter.Link shapes to Azure resources (optional)
For quick reference, add a hyperlink to each Visio shape pointing to the resource’s Azure Portal page. You can get the portal URL from theidfield in your exported JSON (format:https://portal.azure.com/#@<tenant-id>/resource/<resource-id>).Document the snapshot context
Add a text box to your diagram with:- Snapshot date/time
- Source of the export (e.g., ARG query ID, CLI commands used)
- Subscription(s) included
This clarifies that the diagram is a time-point reference, not real-time.
内容的提问来源于stack exchange,提问作者Tdl Matias




