Draw.io Azure infrastructure diagrams through code like an artist
Introduction
In this article we will see how to create an Azure diagram to reveal all the dependencies between Azure App Services, their Application Insights and finally their workspace-based Log Analytics Workspaces.
The use case consist in:
auditing the current configuration on Azure through a PowerShell script,
export the current infrastructure set up on a CSV Draw.io readable file,
observe a work of art.
Concept
To make this piece of art possible you should have a clear idea of the following concept.
Azure resource dependencies: An App Service or Function App can send logs to an Application Insights and Application Insights can send logs to a Log Analytics workspace. This refers to the concept of Workspace-based Application Insights resources.
Draw.io is a free diagram software that permits to insert diagram from specially formatted CSV Data as explained in the following blog.
We can now move on to the next chapter which consists of creating a script that will scan our Infrastructure and write to the CSV in draw.io format.
Script
The following PowerShell script will analyze your App Services configuration based on which ones have these tags and export its results to a local file.
There are 2 main tips on the script you should understand:
The Draw.io “styles” block points out to existing Draw.io shapes, you can print their code by selecting an existing shape, then press Ctrl+E on Windows or Cmd+E on macOS.
You can create multiple connections between your CSV rows with their own properties (labels, line style, etc…).
From Draw.io select Arrange > Insert > Advanced > CSV.
Paste your formatting information and CSV data into the large text field, overwriting the example.
The following screenshot illustrates a diagram generated by the PowerShell script.
Conclusion
We saw in this demo how to draw a script-based Azure App Service oriented diagram. This methodology has no limits and DALL-E knows it, would you defeat it ?