Azure 资源清单
- 作用
- Azure资源清单安装配置
- [PowerShell 登录到 Azure](#PowerShell 登录到 Azure)
- 基本命令
- 输出详细信息
- 效果图展示
作用
官方文档:https://github.com/microsoft/ARI?tab=readme-ov-file#-key-features
Azure 资源清单 (ARI) 是一个全面的 PowerShell 模块,可生成你具有读取访问权限的任何 Azure 环境的详细 Excel 报告。它专为需要一种简单快速的方式来记录其 Azure 环境的云管理员和技术专业人员而设计。
前置条件
- PowerShell 7.0+
- 对要清点的资源具有读取访问权限的 Azure 帐户
- 脚本执行期间的管理员权限(用于模块安装)
安装PowerShell 7.0+
官方文档
python
https://github.com/PowerShell/PowerShell/releases/tag/v7.5.1
- 64位系统:PowerShell-7.5.1-win-x64.msi
- 32位系统:PowerShell-7.5.1-win-x86.msi
查看电脑属性配置的系统类型下载对应powershell

安装时勾选 Add 'Open here' context menu to Explorer(资源管理器右键菜单)
验证
python
pwsh --version

Azure资源清单安装配置
直接从 PowerShell 库安装模块:
python
Install-Module -Name AzureResourceInventory
加载模块
python
Import-Module AzureResourceInventory
如果有旧版本,导致新模块安装不上,进行强制安装
保留旧版本强制安装
python
Install-Module -Name AzureResourceInventory -Force -Scope CurrentUser
安装后查看所有版本
python
Get-Module -Name AzureResourceInventory -ListAvailable | Select-Object Version
PowerShell 登录到 Azure
登录到中国区Azure
python
Connect-AzAccount -EnvironmentName AzureChinaCloud
国际区
python
Connect-AzAccount
PowerShell 登录到 Azure后切换订阅
python
Set-AzContext -Subscription 订阅名
基本命令
使用特定租户运行 ARI:
python
Invoke-ARI -TenantID <Azure-Tenant-ID>
特定订阅的范围:
python
Invoke-ARI -TenantID <Azure-Tenant-ID> -SubscriptionID <Subscription-ID>
在报表中包含资源标签:
python
Invoke-ARI -TenantID <Azure-Tenant-ID> -IncludeTags
输出详细信息
- 默认输出位置:
- windows:C:\AzureResourceInventory\
- Linux/CloudShell的:$HOME/AzureResourceInventory/
- 输出文件名格式:AzureResourceInventory_Report_yyyy-MM-dd_HH_mm.xlsx
- 图表文件名格式:(Draw.io 格式)AzureResourceInventory_Diagram_yyyy-MM-dd_HH_mm.xml
效果图展示
