针对 Azure Cosmos DB 的 Azure Resource Graph 示例查询

适用对象: NoSQL MongoDB Cassandra Gremlin

此页面是针对 Azure Cosmos DB 的 Azure Resource Graph 示例查询的集合。 有关 Azure Resource Graph 示例的完整列表,请参阅 Resource Graph 示例(按类别)Resource Graph 示例(按表)

示例查询

列出具有特定写入位置的 Azure Cosmos DB

以下查询限制为 Azure Cosmos DB 资源,使用 mv-expand 扩展了 properties.writeLocations 的属性包,然后投影了特定字段并将结果进一步限制为 properties.writeLocations.locationName 值(与“中国北部 3”或“中国东部 2”匹配)

Resources
| where type =~ 'microsoft.documentdb/databaseaccounts'
| project id, name, writeLocations = (properties.writeLocations)
| mv-expand writeLocations
| project id, name, writeLocation = tostring(writeLocations.locationName)
| where writeLocation in ('China North 3', 'China East 2')
| summarize by id, name
az graph query -q "Resources | where type =~ 'microsoft.documentdb/databaseaccounts' | project id, name, writeLocations = (properties.writeLocations) | mv-expand writeLocations | project id, name, writeLocation = tostring(writeLocations.locationName) | where writeLocation in ('East US', 'West US') | summarize by id, name"

后续步骤