如何查询Azure存储账户关联的Application Insights组件?
查询Azure存储账户关联的Application Insights组件
目前Azure门户没有直接提供反向查询的入口,你可以通过以下几种方式实现:
Azure CLI 方式
- 先获取目标存储账户的资源ID(可在存储账户的"属性"页面找到)
- 运行以下命令过滤出关联该存储账户的Application Insights组件:
az monitor app-insights component list --query "[?linkedStorageAccounts == '<存储账户资源ID>'].{组件名称:name, 资源组:resourceGroup}"
PowerShell 方式
确保已安装Az.ApplicationInsights模块,然后执行:
# 替换为目标存储账户的资源ID $storageAccountId = "/subscriptions/<订阅ID>/resourceGroups/<资源组>/providers/Microsoft.Storage/storageAccounts/<存储账户名>" Get-AzApplicationInsights | Where-Object { $_.LinkedStorageAccounts -eq $storageAccountId } | Select-Object Name, ResourceGroupName
Azure Resource Graph 查询(高效适用于多订阅场景)
在Azure门户的资源 Graph Explorer中运行以下Kusto查询:
resources | where type == "microsoft.insights/components" | project 组件名称 = name, 资源组 = resourceGroup, 关联存储账户 = properties.linkedStorageAccounts | where 关联存储账户 == "/subscriptions/<订阅ID>/resourceGroups/<资源组>/providers/Microsoft.Storage/storageAccounts/<存储账户名>"
内容的提问来源于stack exchange,提问作者CodeMonkey
相关产品推荐
相关产品推荐

