Azure Depolama için Azure Kaynak Grafı örnek sorguları

Bu sayfa, Azure Kaynak Grafı örnek sorgularından oluşan Azure Depolama için bir toplamadır.

Örnek sorgular

Kaynak grubunda büyük/küçük harfe duyarlı olmayan belirli bir etikete sahip depolama hesaplarını bulma

'Kaynak grubunda belirli bir büyük/küçük harfe duyarlı etikete sahip depolama hesaplarını bul' sorgusuna benzer, ancak büyük/küçük harf duyarlılığı olmadan etiket adı ve etiket değeri aramak gerektiğinde, mv-expandbagexpansion parametresiyle kullanın. Bu sorgu özgün sorgudan daha fazla kota kullandığından, yalnızca gerekirse kullanın mv-expand .

Resources
| where type =~ 'microsoft.storage/storageaccounts'
| join kind=inner (
  ResourceContainers
  | where type =~ 'microsoft.resources/subscriptions/resourcegroups'
  | mv-expand bagexpansion=array tags
  | where isnotempty(tags)
  | where tags[0] =~ 'key1' and tags[1] =~ 'value1'
  | project subscriptionId, resourceGroup)
on subscriptionId, resourceGroup
| project-away subscriptionId1, resourceGroup1
az graph query -q "Resources | where type =~ 'microsoft.storage/storageaccounts' | join kind=inner ( ResourceContainers | where type =~ 'microsoft.resources/subscriptions/resourcegroups' | mv-expand bagexpansion=array tags | where isnotempty(tags) | where tags[0] =~ 'key1' and tags[1] =~ 'value1' | project subscriptionId, resourceGroup) on subscriptionId, resourceGroup | project-away subscriptionId1, resourceGroup1"

Kaynak grubunda büyük/küçük harfe duyarlı belirli bir etikete sahip depolama hesaplarını bulma

Aşağıdaki sorgu, depolama hesaplarını, belirtilen büyük/küçük harfe duyarlı etiket adına ve etiket değerine sahip kaynak gruplarına bağlamak için innerjoin kullanır.

Resources
| where type =~ 'microsoft.storage/storageaccounts'
| join kind=inner (
  ResourceContainers
  | where type =~ 'microsoft.resources/subscriptions/resourcegroups'
  | where tags['Key1'] =~ 'Value1'
  | project subscriptionId, resourceGroup)
on subscriptionId, resourceGroup
| project-away subscriptionId1, resourceGroup1
az graph query -q "Resources | where type =~ 'microsoft.storage/storageaccounts' | join kind=inner ( ResourceContainers | where type =~ 'microsoft.resources/subscriptions/resourcegroups' | where tags['Key1'] =~ 'Value1' | project subscriptionId, resourceGroup) on subscriptionId, resourceGroup | project-away subscriptionId1, resourceGroup1"

Belirli bir etiket değerine sahip tüm depolama hesaplarını listele

Önceki örneğin filtre işlevini birleştirin ve Azure kaynak türünü özelliğe göre type filtreleyin. Bu sorgu da aramayı belirli bir etiket adına ve değerine sahip olan belirli Azure kaynağı türleriyle sınırlar.

Resources
| where type =~ 'Microsoft.Storage/storageAccounts'
| where tags['tag with a space']=='Custom value'
az graph query -q "Resources | where type =~ 'Microsoft.Storage/storageAccounts' | where tags['tag with a space']=='Custom value'"

Depolama içeren kaynakları göster

Bu örnek sorgu, eşleşecek türü açıkça tanımlamak yerine depolamacontainsiçeren herhangi bir Azure kaynağını bulur.

Resources
| where type contains 'storage' | distinct type
az graph query -q "Resources | where type contains 'storage' | distinct type"

Sonraki adımlar