ridicurious.com
Azure, Powershell

Automated Azure Infrastructure Diagrams with PowerShell

Table of Contents


 

Hello friend, Welcome to my blog! 😇

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. 👇

If you like reading my content and projects I pursue follow me on Twitter @singhprateik, for all the updates!


Problem Statement


Introducing ‘Azure Visualizer’ aka ‘AzViz’

Introducing Azure Visualizer aka 'AzViz' – #PowerShell module to automatically generate #Azure resource topology diagrams or rich infrastructure visualizations by just typing a PowerShell cmdlet and passing the name of one or more Azure Resource Group(s). See the following image 👇😇 to understand what this module can generate…

Github Project Repository: https://github.com/PrateekKumarSingh/AzViz

Project is open-source on above URL, please feel free to open issues and collaborate if something is not working for you and I’ll pick them up as soon as I get a moment.

Resumed working on project ‘AzViz’ again after a year during RestUp week (Entire Week off for all LinkedIn employees) here at LinkedIn and making some good progress here and having a blast 😇


Update: There has been few recent releases of this module since this blog post was published, you can find more details and new feature in the module here: Azure Visualizer PowerShell module v1.1.2


Capabilities


Demo Video on Youtube

 


Prerequisite

We need to download and 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

Windows

# chocolatey packages Graphviz for Windows
choco install graphviz

# alternatively using windows package manager
winget install graphviz

Mac

brew install graphviz

Installation of PowerShell Module

From PowerShell Gallery

# install from powershell gallery
Install-Module AzViz -Verbose -Scope CurrentUser -Force

# import the module
Import-Module AzViz -Verbose

# login to azure, this is required for module to work
Connect-AzAccount

Clone the project from GitHub

# optionally clone the project from github
git clone https://github.com/PrateekKumarSingh/AzViz.git
Set-Location .\AzViz\
   
# import the powershell module
Import-Module .\AzViz.psm1 -Verbose

# login to azure, this is required for module to work
Connect-AzAccount

How to use the Module?

Target Single Resource Group

# target single resource group
Export-AzViz -ResourceGroups demo-2 -Theme light -Verbose -OutputFormat png -Show

Target Single Resource Group with more sub-categories

# target single resource group with more sub-categories
Export-AzViz -ResourceGroups demo-2 -Theme light -Verbose -OutputFormat png -Show -CategoryDepth 2

Target Multiple Resource Groups

# target multiple resource groups
Export-AzViz -ResourceGroups demo-2, demo-3 -LabelVerbosity 1 -CategoryDepth 1 -Theme light -Verbose -Show -OutputFormat png

Add Verbosity to Resource Label

# adding more information in resource label like: Name, type, Provider etc
Export-AzViz -ResourceGroups demo-2 -Theme light -Verbose -OutputFormat png -Show -LabelVerbosity 2

Change Theme of Visualization to ‘Dark’ or ‘Neon’

# changing visualization to darker tone
Export-AzViz -ResourceGroup test1 -Verbose -OutputFilePath C:\temp\3.png -Show -LabelVerbosity 2 -Theme dark

Future of this Module?

  • Right now I’m fiddling with two ideas to generate the visualization
    1. using dependsOn property in ARM template to find dependency in an ARM template
    2. and using Network watcher to find associations. Which also provides the network flow like PublicIP > LoadBalancer > NIC > VM. I may end up using both because both have pros and cons, and by overlaying data from both these approaches on the same graph will give amazing details and insights of you Azure infrastructure.
  • Today we only use ‘GraphViz‘ which is open-source visualization software, I will add support for more visualization engines, graphing tools like: Visio, Lucid Charts, etc
  • Ability to expose 'Custom properties' of an Azure resource type on the image, like IPAddress on NIC card etc
  • 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
  • Ability to exclude Azure resource types like Microsoft.Storage/storageAccounts/blobServices
  • Support visualization from ARM templates passed as an URL or a local File - Work in progress!.
  • 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.

 

Author of “PowerShell Guide to Python“, “Windows Subsystem for Linux (WSL)“, “Learn C# in 30 minutes” and currently writing the most awaited book: “PowerShell to C# and Back“!


Subscribe to our mailing list

* indicates required

Related posts

Programmatically Scroll Internet Explorer with PowerShell

Prateek Singh
7 years ago

Book Update: PowerShell Guide to Python is 80% complete!

Prateek Singh
5 years ago

Deep Dive: PowerShell Loops and Iterations

Akshi Srivastava
5 years ago
Exit mobile version