针对 Azure SQL 数据库的 Azure Resource Graph 示例查询

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

示例查询

列出 SQL 数据库及其弹性池

以下查询使用 leftouter 将 SQL 数据库资源及其相关弹性池组合在一起(如果有)。

Resources
| where type =~ 'microsoft.sql/servers/databases'
| project databaseId = id, databaseName = name, elasticPoolId = tolower(tostring(properties.elasticPoolId))
| join kind=leftouter (
    Resources
    | where type =~ 'microsoft.sql/servers/elasticpools'
    | project elasticPoolId = tolower(id), elasticPoolName = name, elasticPoolState = properties.state)
    on elasticPoolId
| project-away elasticPoolId1
az graph query -q "Resources | where type =~ 'microsoft.sql/servers/databases' | project databaseId = id, databaseName = name, elasticPoolId = tolower(tostring(properties.elasticPoolId)) | join kind=leftouter ( Resources | where type =~ 'microsoft.sql/servers/elasticpools' | project elasticPoolId = tolower(id), elasticPoolName = name, elasticPoolState = properties.state) on elasticPoolId | project-away elasticPoolId1"

后续步骤