Git Product home page Git Product logo

prateekkumarsingh / azviz Goto Github PK

View Code? Open in Web Editor NEW
562.0 41.0 139.0 10.96 MB

⚡ ☁ Azure Visualizer aka 'AzViz' : A #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 groups

License: MIT License

PowerShell 100.00%
azure-resource topology-diagram azure automation graphviz dot-language infrastructure-as-code infrastructure-automation graph

azviz's Introduction

⚡ Azure Visualizer, aka 'AzViz'

PowerShell Gallery PowerShell Gallery GitHub issues CI Documentation Status License

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.

Buy Me A Coffee

It is capable of:

  • 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.
  • Insert 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.
  • 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.

Thanks and shoutouts

Special thanks & shoutout to Kevin Marquette and his PSGraph module which seeded the idea for programmatical approach to Azure Visualization while I was working with Kevin's module. And without which 'AzViz' module won't be possible! ♥👍

Demo Video - Youtube

Demo Video

Prerequisite

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

Windows

# chocolatey packages Graphviz for Windows
choco install graphviz

# alternatively using windows package manager
winget install graphviz

Mac

brew install graphviz

Installation

From PowerShell Gallery

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

# import the module
Import-Module AzViz

# 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\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?

Target Single Resource Group

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

Target Single Resource Group with more sub-categories

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

Target Multiple Resource Groups

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

Add Verbosity to Resource Label

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

Change Log

v1.2.1

  • Fixed casing for loadbalancer.png in AzViz/src/private/Images.ps1 to match the filename for AzViz/icons/LoadBalancers.png as AzViz could not find the icon when run from pwsh on a Linux VM. pull-request by @madsaune

v1.2.0

  • Handled condition to skip resources out of resource group, this should fix issue#37 and issue#39
  • Handled period in resource group name, this should fix issue#41
  • If there are no edges between the nodes, then graph legends are not plotted, this should fix issue#38
  • Empty resource groups skips, resource visualization for all later targets, this should fix issue#50. Thanks @madsaune finding the bug and creating the issue.
  • Add Vnet-only resource groups to graph visualization. Special thanks to @madsaune for the pull-request

v1.1.2

  • Network infra and the associated resources are represented in much better way
  • Improve network diagrams with Virtual Networks containing Subnets and resources
  • Azure Icons with labels showing informarion on Subscriptions, RGs, VNet, Subnets
  • Excluding Azure resource types/providers
  • Supports empty virtual networks
  • Improved dark and neon themes
  • Supports diagram legends
  • Bug Fixes

azviz's People

Contributors

brettwhiteinc avatar kzhen avatar moiaune avatar prateekcms avatar prateekkumarsingh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azviz's Issues

Typo in Image file

There is a small typo at the top of img/SingleResourceGroup.jpg, the top picture of readme.md.

The text should probably read Public IP.

Best Practices - RequiredModules

Your "Script Module" file "AzViz.psm1" is installing PSGraph and AZ modules if not found when your module loads. This goes against best practices and shouldn't be handled there. This creates a situation where someone might have this module load from another source and it starts installing modules that they didn't intend to install, and they can't find what module is installing those other modules.

Best Practice would be to use your Module Manifest to specify required modules. In that scenario the offending module that is installing other modules becomes more discoverable.

#Remove This ##Please
# verify dependent modules are loaded $DependentModules = 'PSGraph', 'az' $Installed = Import-Module $DependentModules -PassThru -ErrorAction SilentlyContinue | Where-Object { $_.name -In $DependentModules } $Missing = $DependentModules | Where-Object { $_ -notin $Installed.name } if ($Missing) { Write-Verbose " [+] Module dependencies not found [$Missing]. Attempting to install." Install-Module $Missing -Force -AllowClobber -Confirm:$false -Scope CurrentUser Import-Module $Missing }

-/u/SpacezCowboy

HTTP 404 response on any resource group containing an Application Gateway resource

I've tried against multiple subscriptions and resource groups, they all seem to work except for resource groups containing Application Gateway resources. I get an HTTP 404 not found response, as seen below

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com//subscriptions/[removed]/resourceGroups/[removed]/providers/Microsoft.Network/applicationGateways/[removed]/frontendIPConfigurations/appGatewayFrontendIP?api-version=2016-09-01

Headers:
x-ms-client-request-id : [removed]
Accept-Language : en-US

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
NotFound

Headers:
Cache-Control : no-cache
Pragma : no-cache
Strict-Transport-Security : max-age=31536000; includeSubDomains
Server : Microsoft-HTTPAPI/2.0,Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 11998
x-ms-request-id : [removed]
x-ms-correlation-request-id : [removed]
x-ms-routing-request-id : [location]:20210428T131307Z:[removed]
X-Content-Type-Options : nosniff
Date : Wed, 28 Apr 2021 13:13:06 GMT

Body:
{
"Message": "No HTTP resource was found that matches the request URI 'https://[location].network.azure.com:30010/[removed]/132615493315838172/subscriptions/[removed]/resourceGroups/[removed]/providers/Microsoft.Network/applicationGateways/[removed]/frontendIPConfigurations/appGatewayFrontendIP?api-version=2016-09-01'."
}

Get-AzResource: PowerShell\Modules\AzViz\1.1.2\src\private\ConvertFrom-Network.ps1:90
Line |
90 | … toCateg = (Get-AzResource -ResourceId $to.ResourceId).Resour …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| No HTTP resource was found that matches the request URI
| 'https://[location].network.azure.com:30010/[removed]/132615493315838172/subscriptions/[removed]/resourceGroups/[removed]/providers/Microsoft.Network/applicationGateways/[removed]/frontendIPConfigurations/appGatewayFrontendIP?api-version=2016-09-01'. StatusCode: 404 ReasonPhrase: Not Found OperationID : [removed]

Testing a little bit on my own, I get the same HTTP 404 response on the following uris
applicationGateways/[appgwname]/frontendIPConfigurations/appGatewayPublicIP?api-version=2016-09-01
applicationGateways/[appgwname]/backendAddressPools/[poolname1]?api-version=2016-09-01
applicationGateways/[appgwname]/backendAddressPools/[poolname2]?api-version=2016-09-01

Ability to define resource links to be excluded from the graph.

Some resources have lots of links that make the graph unnecessarily cluttered when you have lots of resources. One example is Log Analytics, as that is often connected to lots of resources to gather logs centrally.

it would be goo to have an option to provide a list of resources for which links should not be generated (the resource should still be on the diagram as it does exist, just without the linking arrows)

Install error when running Install-GraphViz

PS C:\Program Files\AzViz-master> Install-GraphViz

Confirm
Are you sure you want to perform this action?
Performing the operation "Install-GraphViz" on target "Register Chocolatey provider and install graphviz".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): A
VERBOSE: Performing the operation "Install Package" on target "Package 'Graphviz' version '2.38.0.20190211' from
'chocolatey'.".

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'chocolatey'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
VERBOSE: NuGet: WARNING: The request was aborted: Could not create SSL/TLS secure channel.
WARNING: NuGet: System.InvalidOperationException: Unable to find version '1.3.5.1' of package
'chocolatey-core.extension'.
WARNING: NuGet: at NuGet.PackageRepositoryHelper.ResolvePackage(IPackageRepository sourceRepository,
IPackageRepository localRepository, IPackageConstraintProvider constraintProvider, String packageId, SemanticVersion
version, Boolean allowPrereleaseVersions)
WARNING: NuGet: at NuGet.PackageManager.InstallPackage(String packageId, SemanticVersion version, Boolean
ignoreDependencies, Boolean allowPrereleaseVersions)
WARNING: NuGet: at NuGet.Commands.InstallCommand.InstallPackage(IFileSystem fileSystem, String packageId,
SemanticVersion version)
WARNING: NuGet: at NuGet.Program.Main(String[] args)
VERBOSE: Skipped Package 'chocolatey-core.extension v1.3.5.1' already installed
VERBOSE: NuGet: WARNING: The request was aborted: Could not create SSL/TLS secure channel.
WARNING: NuGet: System.InvalidOperationException: Unable to find version '2.38.0.20190211' of package 'Graphviz'.
VERBOSE: Skipped Package 'Graphviz v2.38.0.20190211' already installed
VERBOSE: Skipping installed package Graphviz 2.38.0.2.

After this, when I attempt to run command
Get-AzNetworkVizualization -ResourceGroups 'test-resource-group' -ShowGraph -OutputFor
mat png -Verbose
VERBOSE: Starting topology graph generation
VERBOSE: Target resource groups: 'test-resource-group'
Export-PSGraph : Could not find GraphViz installed on this system. Please run 'Install-GraphViz' to install the needed
binaries and libraries. This module just a wrapper around GraphViz and is looking for it in the following paths:
C:\Program Files\NuGet\Packages\Graphviz*\dot.exe or C:\program files*\GraphViz*\bin\dot.exe or /usr/local/bin/dot or
/usr/bin/dot. Optionally pass a path to your dot.exe file with the GraphVizPath parameter
At C:\Program Files\AzViz-master\AzViz\src\public\Get-AzNetworkVizualization.ps1:199 char:9

  • } | Export-PSGraph -ShowGraph:$ShowGraph -OutputFormat $OutputFor ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Could not find ...zPath parameter:String) [Export-PSGraph], RuntimeEx
      ception
    • FullyQualifiedErrorId : Could not find GraphViz installed on this system. Please run 'Install-GraphViz' to insta
      ll the needed binaries and libraries. This module just a wrapper around GraphViz and is looking for it in the foll
      owing paths: C:\Program Files\NuGet\Packages\Graphviz*\dot.exe or C:\program files*\GraphViz*\bin\dot.exe or /usr/
      local/bin/dot or /usr/bin/dot. Optionally pass a path to your dot.exe file with the GraphVizPath parameter,Export-
      PSGraph

Feature Request: Parameter to supress output

Hi,

First of all, thanks so much for this module. Its golden!

I'm automating visualization of Azure environment using AzViz in a script which generates a visualization for each subscription which in turn means that I must call Export-AzViz multiple times, since I have multiple subscriptions.

The current version of AzViz generates a lot of output in the terminal, so it would be nice if we could have a parameter that would supress this information. I've tried to pipe the command to Out-Null but since it's using Write-Host this does not work.

Could not install GraphViz on this system.

Getting this error - the Install-GraphViz completed successfully too

image

PS C:\Users\us1\Downloads\AzViz-master\AzViz-master> Install-GraphViz
VERBOSE: Performing the operation "Install Package" on target "Package 'Graphviz' version '2.38.0.20190211' from 'chocolatey'.".
VERBOSE: NuGet: WARNING: The request was aborted: Could not create SSL/TLS secure channel.
WARNING: NuGet: System.InvalidOperationException: Unable to find version '1.3.5.1' of package 'chocolatey-core.extension'.
WARNING: NuGet: at NuGet.PackageRepositoryHelper.ResolvePackage(IPackageRepository sourceRepository, IPackageRepository localRepository, IPackageConstraintProvider constraintProvider, String packageId, SemanticVers
ion version, Boolean allowPrereleaseVersions)
WARNING: NuGet: at NuGet.PackageManager.InstallPackage(String packageId, SemanticVersion version, Boolean ignoreDependencies, Boolean allowPrereleaseVersions)
WARNING: NuGet: at NuGet.Commands.InstallCommand.InstallPackage(IFileSystem fileSystem, String packageId, SemanticVersion version)
WARNING: NuGet: at NuGet.Program.Main(String[] args)
VERBOSE: Skipped Package 'chocolatey-core.extension v1.3.5.1' already installed
VERBOSE: NuGet: WARNING: The request was aborted: Could not create SSL/TLS secure channel.
WARNING: NuGet: System.InvalidOperationException: Unable to find version '2.38.0.20190211' of package 'Graphviz'.
VERBOSE: Skipped Package 'Graphviz v2.38.0.20190211' already installed

PS C:\Users\us1\Downloads\AzViz-master\AzViz-master> Get-AzNetworkVizualization -ResourceGroups 'kubernetes' -ShowGraph -OutputFormat png -Verbose
VERBOSE: Starting topology graph generation
VERBOSE: Target resource groups: 'kubernetes'
Export-PSGraph : Could not find GraphViz installed on this system. Please run 'Install-GraphViz' to install the needed binaries and libraries. This module just a wrapper around GraphViz and is looking for it in the
following paths: C:\Program Files\NuGet\Packages\Graphviz*\dot.exe or C:\program files*\GraphViz*\bin\dot.exe or /usr/local/bin/dot or /usr/bin/dot. Optionally pass a path to your dot.exe file with the GraphVizPath
parameter
At C:\Users\us1\Downloads\AzViz-master\AzViz-master\src\public\Get-AzNetworkVizualization.ps1:199 char:9

  • } | Export-PSGraph -ShowGraph:$ShowGraph -OutputFormat $OutputFor ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Could not find ...zPath parameter:String) [Export-PSGraph], RuntimeException
    • FullyQualifiedErrorId : Could not find GraphViz installed on this system. Please run 'Install-GraphViz' to install the needed binaries and libraries. This module just a wrapper around GraphViz and is looking f
      or it in the following paths: C:\Program Files\NuGet\Packages\Graphviz*\dot.exe or C:\program files*\GraphViz*\bin\dot.exe or /usr/local/bin/dot or /usr/bin/dot. Optionally pass a path to your dot.exe file with
      the GraphVizPath parameter,Export-PSGraph

VERBOSE: Graph Exported to path:

Allow generation of graph from Bicep/ARM Templates

As part CD for IaC, I was looking for a way to generate a graph of our infrastructure from Bicep/ARM Templates before ultimately applying them. Hoping to have this happen right before a deployment gate.

I saw that it looks like there was an idea to have this feature from reading Export-AzViz.ps1. Any plan to implement this/turn on?

export-azviz error out with resourc group not found

Executing the following command to a valid Azure resource group:

 Export-AzViz -ResourceGroup azResourceEast01 -Theme light -OutputFormat png -Show;

Giving the following error:

Get-AzResource: C:\Users\max_t\Documents\PowerShell\Modules\AzViz\1.1.2\src\private\ConvertFrom-Network.ps1:90
Line |
  90 |  …      toCateg     = (Get-AzResource -ResourceId $to.ResourceId).Resour …
     |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Resource group 'Cust-t-r-i-n-i-t-y-0-c-o-m-837f9ff1-4a13-4318-9eca-a53a2c969bee' could not be found.
     | StatusCode: 404 ReasonPhrase: Not Found OperationID : 1d257410-fdb9-4773-ae88-69ef5af83c16

I'm not sure what I"m missing!

azviz_err_2021-05-13_16-26-02

Build a graph of all relationships between resources across all resource groups.

It appears that currently the resource groups are all treated independently when identifying relationships. One example is when networking resources are in one resource group and the VM resources are in another. The NICs in the networking resource group are not shown as linked to the VM resources in the VM resource group.

wrong resolution on bigger images

hi, i've used this script succesfully some times, but last one i have tried on a infraestructure with a lot of different resource groups. the result was initially a image like this
image

whem zoom in i get this:

image

the text is all ofuscated and is impossible read them.

Please if anybody with more experience knows how to resolve this issue will be very helpfully. thanks

'Graph' is not recognized as the name of a cmdlet, function

Graph : The term 'Graph' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At C:\Users\xxx\xxxx\Cloud Foundation\AzViz-master\src\public\Get-AzNetworkVizualization.ps1:105 char:5

  • Graph 'AzureTopology' @{overlap = 'false'; splines = 'true' ; ran ...
    
  • ~~~~~
    
    • CategoryInfo : ObjectNotFound: (Graph:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

VERBOSE: Graph Exported to path:

Issue with resource group that has a period in the name

I only have 1 RG with a period in the name, so testing this a bit further on my end is a bit of a challenge.

Output is as follows:

> Export-AzViz -Theme light -OutputFormat png -Show -ResourceGroup website.com_website

    █████╗ ███████╗██╗   ██╗██╗███████╗
   ██╔══██╗╚══███╔╝██║   ██║██║╚══███╔╝   Author    : Prateek Singh (Twitter @singhprateik)
   ███████║  ███╔╝ ██║   ██║██║  ███╔╝    Module    : Azure Visualizer v1.1.2
   ██╔══██║ ███╔╝  ╚██╗ ██╔╝██║ ███╔╝     Github    : https://github.com/PrateekKumarSingh/AzViz
   ██║  ██║███████╗ ╚████╔╝ ██║███████╗   Document  : https://azviz.readthedocs.io
   ╚═╝  ╚═╝╚══════╝  ╚═══╝  ╚═╝╚══════╝
 ▶ Testing Graphviz installation... 253ms
    ▶ GraphViz installation path : C:\Program Files\Graphviz\bin\dot.exe
 ▶ Configuring Defaults... 284ms
    ▶  Target Type            : Azure Resource Group
    ▶  Output Format          : png
    ▶  Exluded Resource Types :
    ▶  Output File Path       : C:\Users\tima\AppData\Local\Temp\output.png
    ▶  Label Verbosity        : 1
    ▶  Category Depth         : 1
    ▶  Sub-graph Direction    : top-to-bottom
    ▶  Theme                  : light
    ▶  Launch Visualization   : True
 ▶ Target Azure Resource Groups...  300ms
 ▶ Starting to generate Azure visualization... 308ms
    ▶ Exporting network associations for resource group: 'website.com_website'
       ▶ Network watcher found: 'NetworkWatcher_canadacentral'
       ▶ Obtaining network topology using Network Watcher
    ▶ Exporting ARM template of Azure resource group: 'website.com_website'
       ▶ Processing the ARM template to extract resources
       ▶ Total resources found: 13
       ▶ Cleaning up temporary ARM template file at: C:\Users\tima\AppData\Local\Temp\tmpBEE8.tmp.json
    ▶ Plotting sub-graph for Azure Resource Group: "website.com_website" 49.57s
       ▶ Creating Nodes
          ▶ microsoft.network/publicipaddresses/sitewebserver-ip
          ▶ microsoft.network/networkinterfaces/sitewebserver120
          ▶ microsoft.compute/virtualmachines/sitewebserver
          ▶ microsoft.compute/sshpublickeys/sitewebserver_key
       ▶ Creating Edges
          ▶ microsoft.network/publicipaddresses/sitewebserver -> ip  microsoft.network/networkinterfaces/sitewebserver120
          ▶ microsoft.network/networkinterfaces/sitewebserver120 ->  microsoft.compute/virtualmachines/sitewebserver
          ▶ microsoft.network/networkinterfaces/sitewebserver120 ->  microsoft.network/publicipaddresses/sitewebserver ip
          ▶ microsoft.compute/virtualmachines/sitewebserver ->  microsoft.network/networkinterfaces/sitewebserver120
          ▶ microsoft.network/networkinterfaces/sitewebserver120 ->  microsoft.network/publicipaddresses/sitewebserver ip
          ▶ microsoft.compute/virtualmachines/sitewebserver ->  microsoft.network/networkinterfaces/sitewebserver120
Error: C:\Users\tima\AppData\Local\Temp\temp.dot: syntax error in line 20 near '.'

Running against an RG that does not have a period in the name (but generally the same configuration - a VM with a public IP) yields a successful output.

Feature Request: Output to Visio

Feature Request: Output to Visio

Justification:
Allow editing of exported diagrams for additional markup/narration.

Probably only valid on a Windows system unless Visio for Web has the necessary features/hooks.

ForEach-Object : The term 'Edge' is not recognized as the name of a cmdlet, function, script file, or operable program

Command run:

Export-AzViz -ResourceGroup tce-uks-hub-001-rg -Theme light -OutputFormat png

Error:

ForEach-Object : The term 'Edge' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At C:\dev\azviz\azviz\src\private\ConvertTo-DOTLangauge.ps1:139 char:17

  •             ForEach-Object {
    
  •             ~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (Edge:String) [ForEach-Object], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.ForEachObjectCommand

Environment:

OS: Windows 10 20H2
Powershell: 5.1.19041.1023
AzViz: 1.2.1
GraphiViz: 2.47.3

I cloned the GitHub repo and ran the import command.

Thanks for the efforts so far - looks like a great solution.

Several unusual bugs on Windows 10

Think Pad P1 Gen3
Windows 10 64-bit 21H1 Build 19043.1165
PSVersion 7.1.4
PSEdition Core
GraphViz 2.48
AzViz 1.2.1

Installing the prerequisites:

winget install graphviz
Install-Module AzViz
Import-Module AzViz
Connect-AzAccount [Parameters]

Given the command (where $foo is a list of five resource group names):

export-azviz -ResourceGroup $foo  -Theme light -OutputFormat svg -Show -LabelVerbosity 2 -Direction top-to-bottom

I'm seeing the following unusual behaviour that appears to be parameter-independent:

  • All of our subscription and resource group names have '-' characters in them; these characters are removed from the resource group names in the SVG output
  • The -Direction parameter does nothing; all resource groups are always laid out left-to-right
  • One of the resource groups is out of alignment, raised approx 1/5th a resource group shape height above the other resource groups

Running under WSL2 on the same system:

NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
PSVersion 7.14
PSEdition Core
GraphViz 2.42.2
AzViz 1.2.1

Installing prereqs:

sudo apt install graphviz
install-module azviz
import-module azviz
connect-azaccount [parameters]

The same command

export-azviz -ResourceGroup $foo  -Theme light -OutputFormat svg -LabelVerbosity 2 -Direction top-to-bottom -OutputFilePath ./foo.svg

produces the same errors, with the additional bug of no Azure icons - all the icons are the "broken image" icon.

I'm going to try on a different system in case this is machine-specific

Include required module or document requirement

Use of the Export-PSGraph command means the PSGraph module has to be installed for the functionality to exists on a given user's machine. I was not able to find any direct reference to this in the README file.

Options would be to either include this in your manifest, document it in your README, or have the function check if the module exists before trying to call the export command.

Space in username results in systematic error when using Export-AzViz

Hello Prateek

Very nice work !! Congrats 👍

I have an issue when using the module. My username contains a space on windows, when I run the command I get this error :

Export-PSGraph : The term 'C:\Users\Lucas' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Lucas Bouvy\Desktop\GIT\AzViz\AzViz\src\public\Export-AzViz.ps1:274 char:6

  • "@ | Export-PSGraph -ShowGraph:$Show -OutputFormat $OutputFormat -Des ...
  •  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (C:\Users\Lucas:String) [Export-PSGraph], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException,Export-PSGraph

I tried to "cheat" by setting manual paths in Export-AzViz.ps1 parameters, but didn't manage to make it work

I assume it is because of the space in my username. I will try on another account with no space and let you know

appservice not linked to subnet

I've got a resource group which contains an app service plan with a single app service that is in a subnet in the same resource group. These two items are both visualised in output but no link is drawn between the two.

image

In the above image, app-<blank>-prod-uksouth is the appService that is in the subnet subnet-<blank>-uks

Should this association be visualised?
I have checked the ARM template that is exported by Export-AzResourceGroup and the vnetName is exported in the Microsoft.Web/sites/config block for the app service.
The vNet is not present in any dependsOn block.

From looking at the code, I don't think it is expected that this would be picked up but wanted to double-check.

Error: SubGraph is not recognized

Command:
Export-AzViz -ResourceGroup "test-rg" -Theme light -OutputFormat png -Show

Error:

ConvertTo-DOTLanguage: /Users/jaredr/Documents/Repos/AzViz/AzViz/src/public/Export-AzViz.ps1:269:18
Line |
 269 |  …    $graph = ConvertTo-DOTLanguage -TargetType $TargetType -Targets $T …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The term 'SubGraph' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling
     | of the name, or if a path was included, verify that the path is correct and try again.

Error when creating Image

Hi,

Not sure what is going on, but when trying to run this on one of my Resource Groups I get the following error.

▶ Plotting sub-graph for Azure Resource Group: "RGName" 5m 12s

Get-ImageNode : Error formatting a string: Index (zero based) must be greater than or equal to zero and less than the size of the argument list..
At C:\Users\username\Documents\WindowsPowerShell\Modules\AzViz\1.2.1\src\private\ConvertTo-DOTLangauge.ps1:182 char:39

  • ... $nodes += Get-ImageNode -Name "$tocateg/$to".tolower() -Rows ($to, ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (<TD align="...FONT>:String) [Get-ImageNode], RuntimeException
    • FullyQualifiedErrorId : FormatError,Get-ImageNode

Import-Module fails on Ubuntu

PS /> Import-Module azviz -Verbose
VERBOSE: Loading module from path '/home/prateek/.local/share/powershell/Modules/AzViz/1.0.1/AzViz.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module AzViz.
VERBOSE: Loading module from path '/home/prateek/.local/share/powershell/Modules/AzViz/1.0.1/AzViz.psm1'.
Get-Package: /home/prateek/.local/share/powershell/Modules/AzViz/1.0.1/AzViz.psm1:19
Line |
19 | if(!(Get-Package GraphViz)){
| ~~~~~~~~~~~~~~~~~~~~
| No package found for 'GraphViz'.

VERBOSE: No match was found for the specified search criteria and provider name 'Chocolatey'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'Chocolatey','','0.0.0.1','''.
Find-Package: /home/prateek/.local/share/powershell/Modules/AzViz/1.0.1/AzViz.psm1:21
Line |
21 | Find-Package graphviz | Install-Package -ForceBootstrap -Verbose
| ~~~~~~~~~~~~~~~~~~~~~
| No match was found for the specified search criteria and package name 'graphviz'. Try Get-PackageSource to see all available registered package sources.

export-azviz doesn't work wih ADF resources.

I'm sure this may be a new one for you! export-azviz doesn't work with ADF resources.
Export-AzViz -ResourceGroup "xxxazadfrg01" -Theme light -Verbose -OutputFormat png -Show;

error: ▶ No resources found.. re-run the command and try increasing the category depth using -CategoryDepth 2 or -CategoryDepth 3 cmdlet parameters. 5.46s
azvizErrWwithADF2021-07-16_9-49-39

Issue: failure anomalies - [resource name]

I am getting Edge and Nodes that are being created with the names "failure anomalies - [resource name]". They have the generic icon, so I am not sure what resource it is actually failing on, and the temporary armtemplate.json is being cleaned up before I have a chance to view where the issue might be.

image

Vpn Gateways

Finally we launched the cmdlets accross subscriptions and we had found that it doesn´t shows Azure VPN Gateways.

More info can be show about Ports configured on NSG, right now only takes the name of the rule.

Great job man!!!!!

Feedback - Output.png filename.

Just a feedback!

I'm sure you could generate the output file name with resource group name, or provide a parameter to name the output file.

The access token is from the wrong issuer

I encounter an issue while using Powershell 5.1 and 7.2 authenticated using my Subscription administrator account (Connect-AzAccount -UseDeviceAuthentication):

Get-AzResource : The access token is from the wrong issuer
'https://sts.windows.net/xxxxxxxx-xxxxxx-xxxxxxx-xxxxxxx/'. It must match the tenant
'https://sts.windows.net/xxxxxxxx-xxxxxx-xxxxxxx-xxxxxxx/' associated with this subscription. Please use the
authority (URL) 'https://login.windows.net/xxxxxxxx-xxxxxx-xxxxxxx-xxxxxxx' to get the token. Note, if the
subscription is transferred to another tenant there is no impact to the services, but information about new tenant
could take time to propagate (up to an hour). If you just transferred your subscription and see this error message,
please try back later.
At C:\Users\rfabiano_wa\AzViz\AzViz\src\private\ConvertFrom-Network.ps1:90 char:48

  • ... toCateg = (Get-AzResource -ResourceId $to.ResourceId).Resour ...
  •                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : CloseError: (:) [Get-AzResource], CloudException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet

I think this may be because I am a Subscription Administrator but not a tenant administrator.

Resource Dependency requirements

I did Export-AzViz and used all of the default values but the only resource dependency arrow drawn was from a web app to the resource group. Under what circumstances would a dependency be drawn between a web app and application insights, for example?

Direction Parameter Bug

Specifying left-to-right no longer functions. It will default to top-to-bottom regardless of entry.

AzViz not finding existing resource groups.

When running "Export-AzViz -ResourceGroup prod01 -Theme light -Verbose -OutputFormat png -Show -CategoryDepth 2" I get a return of the below:

VERBOSE: Target Azure Resource Groups:
VERBOSE: > 'prod01'
VERBOSE: Starting to generate Azure visualization...
VERBOSE: Testing Azure login
VERBOSE: [+] Exporting ARM template of Azure Resource group: "prod01"
Export-AzResourceGroup : ResourceGroupNotFound : Resource group 'prod01' could not be found.
CorrelationId: 2fde82a2-f5b9-4825-8c6f-e01ad27039f7
At C:\Users\Giles\Documents\WindowsPowerShell\Modules\AzViz\1.0.9\src\public\Export-AzViz.ps1:232 char:34

  • ... template = (Export-AzResourceGroup -ResourceGroupName $target -SkipAl ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : CloseError: (:) [Export-AzResourceGroup], ErrorResponseMessageException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ExportAzureResourceGroupCmdlet

In the account there is prod01, dev01 and dev02, but are also 10 subscriptions. I don't see a way to ensure it's picking the right one, which I'm guessing is the issue?

Skips rest of $Targets if a resource group does not contain any resources

I think I found a bug in ConvertFrom-ARM.ps1.

On line 83 it will break out of the foreach loop if a resource group does not contain any resources, which means that I will skip rest of whats in $Targets.

Example:

Let's say you have 4 resource groups.

  • my-rg-1 (contains resources)
  • my-rg-2 (is empty)
  • my-rg-3 (contains resources)
  • my-rg-4 (contains resource)

According to the script it will not check my-rg-3 and my-rg-4, since my-rg-2 is empty.

I think this should be a continue statement instead.

Don't install dependencies when importing the module

Please don't install dependencies when importing the module. This means that, even if you only installed the module to look at what commands Get-Command -Module 'AzViz' and paramters Get-Help -Name '<some-function>- -Parameter '*', AzViz will prompt to install Chocolatey and GraphViz.

Please move this to a function that other functions can use and trigger.

Verify if network watcher is enabled

Verify if network watcher is enabled, though it is enabled by default and will create a network watcher as soon as we create network components in the Azure, but sometimes this feature is disabled by the Azure admin. And non-existence if this will fail the script.

Graph is too large and the file is unreadable

I am getting "dot: graph is too large for cairo-renderer bitmaps. Scaling by 0.21379 to fit" or "Export-AzResourceGroup : ExportTemplateResourcesLimitExceeded : Export template is not supported for resource groups
that have more than '200' resources.
" if run against larger RG

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.