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