DEV Community

loading...
Cover image for Azure Visualizer : Automated Diagrams using PowerShell

Azure Visualizer : Automated Diagrams using PowerShell

prateeksingh profile image Prateek Singh ・5 min read

Problem Statement

Before we jump into understanding why and how we can visualize and document Azure infrastructure, let’s take a pause here and talk a little bit about what are the challenges and problems in current visualization tools and in the approach of manual documentation. 👇

Manual Documentations

Cloud admins are doomed to manually document a cloud environment or infrastructure! As the environment grows it becomes complex to maintain the documentation. There has to be a better way to do this in an automated approach!

Maintaining and updating the documentation

It is painful inheriting an undocumented cloud landscape to support. But the bigger problem is manual documentation consumes a lot of effort and time and it is static in nature and you have to update your documentation after regular intervals.

Gaps in existing tools

There are some visualization tools like Armviz.io and VSCode Extension for ARM Template Visualizer (I love this extension), but I can only target one ARM template at a time use these.

What if I want ability target a real Azure environment(s) or multiple resource groups at once, without downloading the template for an individual resource group? There has to be a better which is automated, modular, and extensible so that we can import it and write our own custom tooling on top of that.. that is why PowerShell comes into the picture.

Basic visualizations

Not many insights from the graphs and diagrams unless you spend a week designing them manually.

No mechanism to change the label verbosity. What if I want to see the resource category, or sku or OS profile of a Virtual machine like Windows, Linux etc? right now you can’t get that..

What if I want to see the resource dependencies and network flow? not possible with existing tools.


Introducing ‘Azure ☁ Visualizer’ aka ‘AzViz’ ⚡

Azure Visualizer aka 'AzViz' - PowerShell module to automatically generate Azure resource topology diagrams by just typing a PowerShell cmdlet and passing the name of one or more Azure Resource Group(s).

Cloud admins are not anymore doomed to manually document a cloud environment! The pain of inheriting an undocumented cloud landscape to support is gone 😎😉 so please share this project with your colleagues and friends.

See the following image 👇😇 to understand what this module can generate…

Azure Resources Visualized

GitHub Project Repository: https://github.com/PrateekKumarSingh/AzViz
Read more on my blog: https://ridicurious.com/tag/azviz/
Read the docs here: https://azviz.readthedocs.io/en/latest/


Capabilities

  • Finding Resources in a Azure Resource Group and identifying their dependencies.
  • Plot nodes and edges to represent Azure Resources and their dependencies on a graph.
  • Inserts appropriate Azure Icons on basis of resource category/sub-category.
  • Label each resource with information like Name, Category, Type etc.
  • Generate visualization in formats like: .png and .svg
  • Output image can be in light, dark or neon theme.
    Alt Text

  • Can target more than one resource group at once.

  • Change direction in which resource groups are plotted, i.e, left-to-right or top-to-bottom.

  • Network infrastructure and the associated resources are represented in much better way, by visualizing Virtual Networks containing Subnets and resources inside it.

  • Azure Icons with labels showing information on Subscriptions, RGs, VNet, Subnets
    Alt Text

  • Excluding any Azure resource types/providers, that you don't want to visualize

  • Supports empty virtual networks
    Alt Text

  • Supports diagram legends
    Alt Text


    Quickstart

We need to install GraphViz on our system before we can proceed with using the 'AzViz' PowerShell module. Depending upon the operating system you are using please follow the below mentioned steps:

Linux
# Ubuntu
$ sudo apt install graphviz

# Fedora
$ sudo yum install graphviz

# Debian
$ sudo apt install graphviz
Enter fullscreen mode Exit fullscreen mode
Windows
# chocolatey packages Graphviz for Windows
choco install graphviz

# alternatively using windows package manager
winget install graphviz
Enter fullscreen mode Exit fullscreen mode
Mac
brew install graphviz
Enter fullscreen mode Exit fullscreen mode

Installation

From PowerShell Gallery
# install from powershell gallery
Install-Module -Name AzViz -Scope CurrentUser -Repository PSGallery -Force

# import the module
Import-Module AzViz -Verbose

# login to azure, this is required for module to work
Connect-AzAccount
Enter fullscreen mode Exit fullscreen mode
Clone the project from GitHub
# optionally clone the project from github
git clone https://github.com/PrateekKumarSingh/AzViz.git
cd .\AzViz\

# import the powershell module
Import-Module .\AzViz.psm1 -Verbose

# login to azure, this is required for module to work
Connect-AzAccount
Enter fullscreen mode Exit fullscreen mode

Using the Module

Following are few ways to use the module to generate visualization of your Azure infrastructure:

# Visualizing a single resource group
Export-AzViz -ResourceGroup demo-2 -Theme light -OutputFormat png -Show

# Visualizing a single resource group with more sub-categories
Export-AzViz -ResourceGroup demo-2 -Theme light -OutputFormat png -Show -CategoryDepth 2

# Visualizing multiple resource groups
Export-AzViz -ResourceGroup demo-2, demo-3 -LabelVerbosity 1 -CategoryDepth 1 -Theme light -Show -OutputFormat png

# Add more information in resource label like: Name, type, Provider etc using the '-LabelVerbosity' parameter
Export-AzViz -ResourceGroup demo-2 -Theme light -OutputFormat png -Show -LabelVerbosity 2

# Exclude Azure resources/providers from the visualization by passing them as an argument to the '-ExcludeTypes' parameter

Export-AzViz -ResourceGroup prateek -Show -ExcludeTypes "*workspace*", "Microsoft.Storage*" -Theme Neon
Enter fullscreen mode Exit fullscreen mode

Future of this Module

I've long term plans for this module and will keep evolving this going forward which you can find here:

But on a high-level, these are area's I want to focus:

Ability to edit the diagrams

Today I use GraphViz which is open-source visualization software, but gradually I will add support for more visualization engines, graphing tools like: Visio, Lucid Charts, etc

Extensibility

I strongly believe users should have more control on how visualization is generated. And one important aspect is giving user ability to expose 'Custom properties' of an Azure resource type on the image, like IPAddress on NIC, OS Profile: Windows or Linux on Virtual Machines etc.

Clustering Logically Related Azure Resources

Right now, the module doesn't support clustering similar resources and subcategories into a logical cluster/group. This is a work in progress and would make the diagram much easier to understand once implemented.

Infrastructure Changes / Differences

Infrastructure DIFF! yeah, you heard it right this is going to be my favorite feature to implement. This will give us the 'ability to identify/detect what has changed in Azure infrastructure', for example, a resource has been deleted, or IPAddress has been changed something like that.

Discussion (0)

Forem Open with the Forem app