PrateekKumarSingh / AzViz

⚡ ☁ 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
MIT License
584 stars 146 forks source link

Multiple StorageAccounts in ResourceGroup results in Error #79

Open karyn3864 opened 2 years ago

karyn3864 commented 2 years ago

Several of our ResourceGroups have multiple StorageAccounts. It seems to be the cause of the resulting error:

ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the duplicated keys 'StorageAccount' and 
'storageAccount'.
At C:\Program Files\WindowsPowerShell\Modules\AzViz\1.2.1\src\private\ConvertFrom-ARM.ps1:72 char:50
+             $arm = Get-Content -Path $template | ConvertFrom-Json
+                                                  ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-Json], InvalidOperationException
    + FullyQualifiedErrorId : DuplicateKeysInJsonString,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
karyn3864 commented 2 years ago

I was able to address this issue by updating ConvertFrom-ARM.ps1:71:

FROM: $arm = Get-Content -Path $template | ConvertFrom-Json TO: $arm = Get-Content -Path $template | ConvertFrom-Json -AsHashtable