Azure Reports: Exporting Azure resources with Powershell and Azure CLI
A common scenario when we work with DevOps and cloud is the need to export information about your resources. In this post, I’ll show the simplest way to extract that with the command line.
The idea of this post is to show the mechanism behind the extraction, I’ll run a simple command to recover the resources and choose some columns to export to a CSV file. You can use this as a base of more complex reports to handle properties, cross with other information, etc.
The first step is to connect in our Azure Account using Azure CLI (you can also do it using Azure Powershell), and recover all resources in our subscription:
Then we create an Array List to populate, iterate on the resources recovered above, and add the needed fields on the array:
Now we create a file name based on date and time to export the populated array. In my case I’m using the Delimiter “;”, as in my favorite regionalization this is the default pattern for CSV files. If this is not your case, you can remove that parameter.
This is the complete script, including the outputPath parameter:
And this is the file exported:
This is the link for my GitHub repository, and the intention is to fill it with more complex reports :)
See you in the next post!