How to export the list of Azure Resources to Excel?

How to export the list of Azure Resources to Excel?

To export the list of Azure resources to excel, you need to take help of Azure Cmdlet PowerShell Script. Using the PowerShell script, you can easily export the Azure subscription inventory. We need to take help of two cmdlet to achieve this.

Export list of Azure Resources to Excel

The Get-AzureRmResource cmdlet gets Azure resources for the selected subscription, and The Export-Csv cmdlet helps in export data as a comma-separated values (CSV) file. Thereafter you can open the same using Excel for your further data manipulation.

Related Post: Azure Cloud Shell in Visual Studio Code

First, Connect with Azure Account, and select the necessary subscription

Connect-AzureRmAccount

 

If you have multiple subscription, set the context to a specific subscription

Set-AzureRmContext -SubscriptionId 4e3b720e-12X3-4XXXc-a35a-bXYXYXXXXbYYX

 

Once the subscription is set, execute the following command

Get-AzureRmResource | Export-Csv -Path "D:\azureinventory.csv"

Once the command execution is completed, you can open the CSV file in excel. With a little formatting and data manipulation, you can have your detailed inventory in excel.

export list of Azure Resources to Excel

Get-AzureRMResource cmdlet returns following

Get-AzureRmResource

   [[-Name] <String>]

   [-ResourceType <String>]

   [-ODataQuery <String>]

   [-ResourceGroupName <String>]

   [-TagName <String>]

   [-TagValue <String>]

   [-ExpandProperties]

   [-ApiVersion <String>]

   [-Pre]

   [-DefaultProfile <IAzureContextContainer>]

   [<CommonParameters>]

You may not be looking for all these details to be exported. In that case, you can export only the fields by mentioning them as Select-Object.

Get-AzureRmResource | Select-Object Name, ResourceGroupName | Export-Csv -Path "D:\ azureinventory.csv"

In this case, the exported CSV will have only the Resource Name, and Resource Group.

export list of Azure Resources to Excel - Filtered

This could be extremely helpful to manage and maintain your azure inventory along with prepare quick reports related to the inventory as shown in the below image.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.