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

dot.exe : Error: <stdin>: syntax error in line 1 near 'strict' #96

Open Marcus-James-Adams opened 2 years ago

Marcus-James-Adams commented 2 years ago

For most of my resource groups it works ok, however for some I get a recurring error eg

█████╗ ███████╗██╗ ██╗██╗███████╗
██╔══██╗╚══███╔╝██║ ██║██║╚══███╔╝ Author : Prateek Singh (Twitter @singhprateik) ███████║ ███╔╝ ██║ ██║██║ ███╔╝ Module : Azure Visualizer v1.2.1 ██╔══██║ ███╔╝ ╚██╗ ██╔╝██║ ███╔╝ Github : https://github.com/PrateekKumarSingh/AzViz ██║ ██║███████╗ ╚████╔╝ ██║███████╗ Document : https://azviz.readthedocs.io ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝
▶ Testing Graphviz installation... 999ms ▶ GraphViz installation path : C:\Program Files (x86)\Graphviz\bin\dot.exe ▶ Comciguring Defaults... 1.10s ▶ Target Type : Azure Resource Group ▶ Output Format : png ▶ Exluded Resource Types : ▶ Output File Path : C:\repo\orgs\mycomp\cloud_imcrastructure\projects\platform\dev\UK_South\2.1.3.sql-managed-instance\imcrastructure_diagram.png ▶ Label Verbosity : 2 ▶ Category Depth : 1 ▶ Sub-graph Direction : top-to-bottom ▶ Theme : light ▶ Launch Visualization : False ▶ Target Azure Resource Groups... 1.17s ▶ mc-dev-uks-sqlmi-rsg ▶ Starting to generate Azure visualization... 1.18s VERBOSE: Testing Azure login ▶ Exporting network associations for resource group: 'mc-dev-uks-sqlmi-rsg' ▶ Network watcher found: 'NetworkWatcher_uksouth' ▶ Obtaining network topology using Network Watcher ▶ Exporting ARM template of Azure resource group: 'mc-dev-uks-sqlmi-rsg' ▶ Processing the ARM template to extract resources ▶ Total resources found: 31 ▶ Cleaning up temporary ARM template file at: C:\Users\marcus.adams\AppData\Local\Temp\tmp54C0.tmp.json ▶ Plotting sub-graph for Azure Resource Group: "mc-dev-uks-sqlmi-rsg" 10.41s ▶ Creating Nodes ▶ microsoft.sql/managedinstances/mc-dev-uks-sqlmi-sql2 ▶ microsoft.sql/managedinstances/mc-dev-uks-sqlmi-sql1 dot.exe : Error: : syntax error in line 1 near 'strict' At C:\Users\marcus.adams\OneDrive - Novia Financial\Documents\WindowsPowerShell\Modules\PSGraph\2.1.38.27\PSGraph.psm1:904 char:53

Export-PSGraph : System error. At C:\repo\orgs\mycomp\AzViz\AzViz\src\public\Export-AzViz.ps1:274 char:6

laurentcardon commented 2 years ago

Same error. I added a breakpoint on PSGraph.psm1 script line 904 to get the value of $standardInput.ToString() and attached to the thread. standardinput.txt

chems commented 2 years ago

Hello, Same error, any solution, Thx in advance

gstevens-kyriba commented 2 years ago

I had this same issue when trying to run this on a self-hosted build agent. I was able to fix this by modifying the installed C:\Program Files\WindowsPowerShell\Modules\AzViz\1.2.1\src\public\Export-AzViz.ps1 file. I didn't have any problems running Export-AzViz from Powershell locally, but when I tried to run it in an Azure DevOps pipeline, it would fail on this line. I reformatted the line and learned a bit about here strings..

I added a $combined variable to catch the concatenation.. In the end, its just trying to add "strict" to the graph output before passing it to Export. This resolved the issue running from my build machine.

image

before changes: image

after: image

gstevens-kyriba commented 2 years ago

yaml steps to generate diagrams from an Azure Devops pipeline: I pre-installed Az-Viz, etc on the build agent, then put this in the pipeline. create a variable called "resource_groups" and put a list of the resource groups you want to model. output.png will get attached to the pipeline as an artifact. ` steps:

Marcus-James-Adams commented 1 year ago

it seems a few people get this @gstevens-kyriba would you mind submitting a PR with your fix in it so all could benefit?

jhonnybello commented 7 months ago

Hi Here, I'm having the same issue!

`dot.exe : Error: : syntax error in line 1 near 'strict' At C:\Program Files\WindowsPowerShell\Modules\PSGraph\2.1.38.27\PSGraph.psm1:904 char:53

Export-PSGraph : System error. At C:\Program Files\WindowsPowerShell\Modules\AzViz\1.2.1\src\public\Export-AzViz.ps1:274 char:6