Note: if you are running CloudGraph locally you can view the interactive, automatically generated documentation in either GraphQL Playground or Altair by clicking the docs button on the right-hand side of the screen. After reading the below information we highly suggest you use one of these tools to test your queries as they will autocomplete fields for you and let you know if your queries are valid before you even submit them.
You can currently query the following attributes and connections on an Azure Cosmos DB
query {
queryazureCosmosDb {
id
name
type
kind
subscriptionId
region
resourceGroupId
provisioningState
documentEndpoint
databaseAccountOfferType
createdBy
createdByType
createdAt
lastModifiedBy
lastModifiedByType
lastModifiedAt
isVirtualNetworkFilterEnabled
enableAutomaticFailover
enableMultipleWriteLocations
enableCassandraConnector
connectorOffer
disableKeyBasedMetadataWriteAccess
keyVaultKeyUri
defaultIdentity
publicNetworkAccess
enableFreeTier
apiServerVersion
enableAnalyticalStorage
analyticalStorageConfigurationSchemaType
instanceId
createMode
networkAclBypass
networkAclBypassResourceIds
disableLocalAuth
capacityTotalThroughputLimit
tags {
id
key
value
}
identity {
principalId
type
tenantId
userAssignedIdentities {
id
key
value {
principalId
clientId
}
}
userAssignedIdentitiesAggregate {
count
idMin
idMax
keyMin
keyMax
}
}
ipRules {
id
ipAddressOrRange
}
consistencyPolicy {
defaultConsistencyLevel
maxStalenessPrefix
maxIntervalInSeconds
}
capabilities {
id
name
}
writeLocations {
id
locationName
documentEndpoint
provisioningState
failoverPriority
isZoneRedundant
}
readLocations {
id
locationName
documentEndpoint
provisioningState
failoverPriority
isZoneRedundant
}
locations {
id
locationName
documentEndpoint
provisioningState
failoverPriority
isZoneRedundant
}
failoverPolicies {
id
locationName
failoverPriority
}
virtualNetworkRules {
id
ignoreMissingVNetServiceEndpoint
}
privateEndpointConnections {
id
name
type
privateEndpointId
privateLinkServiceConnectionState {
status
description
actionsRequired
}
groupId
provisioningState
}
restoreParameters {
restoreMode
restoreSource
restoreTimestampInUtc
databasesToRestore {
id
databaseName
collectionNames
}
databasesToRestoreAggregate {
count
idMin
idMax
databaseNameMin
databaseNameMax
}
}
backupPolicy {
type
migrationState {
status
targetType
startTime
}
periodicModeProperties {
backupIntervalInMinutes
backupRetentionIntervalInHours
backupStorageRedundancy
}
}
cors {
id
allowedOrigins
allowedMethods
allowedHeaders
exposedHeaders
maxAgeInSeconds
}
databases {
id
name
type
options {
throughput
maxThroughput
}
resource {
id
rid
ts
etag
}
data {
id
name
type
}
}
azureTables {
id
name
type
options {
throughput
maxThroughput
}
resource {
id
rid
ts
etag
}
}
resourceGroup {
id
}
}
}
Get data for a single Azure Cosmos DB key that you know the ID for:
query {
getazureCosmosDb(id: "12345") {
id
}
}
Get data for all of the Azure Cosmos DB in a certain region:
query {
queryazureCosmosDb(filter: { region: { eq: "eastus" } }) {
id
}
}
Get data for all of the Azure Cosmos DB that are NOT in a certain Azure subscription:
query {
queryazureCosmosDb(filter: { not: { subscriptionId: { eq: "12345" } } }) {
id
}
}
Get data for all of the Azure Cosmos DB that
query {
queryazureCosmosDb(filter: { has: resourceGroup }) {
id
}
}
You can order the results you get back either asc or desc depending on your preference:
query {
queryazureCosmosDb(order: { desc: name }) {
id
}
}
Only select and return the first two Azure Cosmos DB that are found:
query {
queryazureCosmosDb(first: 2, order: { desc: name }) {
id
}
}
Only select and return the first two Azure Cosmos DB that are found, but offset by one so keys two & three are returned:
query {
queryazureCosmosDb(first: 2, order: { desc: name }, offset: 1) {
id
}
}
Count the number of Azure Cosmos DB across all scanned Azure subscriptions:
query {
aggregateazureCosmosDb {
count
}
}
Count the number of Azure Cosmos DB in a single account. Note that you can apply all of the same filters that are listed above to aggregate queries:
query {
aggregateazureCosmosDb(filter: { subscriptionId: { eq: "12345" } }) {
count
}
}
Find all of the Azure Cosmos DB that are in the eastus region across all your accounts:
query {
aggregateazureCosmosDb(filter: { region: { eq: "eastus" } }) {
id
}
}
Find all of the Azure Cosmos DB that have a tag of Environment:Production for a single Azure Subscription:
query {
queryazureTag(
filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
) {
cosmosDb(filter: { subscriptionId: { eq: "12345" } }) {
id
}
}
}
With CloudGraph you can run multiple queries at the same time so you can combine the above two queries if you like:
query {
queryazureCosmosDb(filter: { region: { eq: "eastus" } }) {
id
}
queryazureTag(
filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
) {
cosmosDb(filter: { subscriptionId: { eq: "12345" } }) {
id
}
}
}
Putting it all together; get all data for all Azure Cosmos DB across all regions for all scanned Azure subscriptions in a single query. For the purposes of this example, we will only get direct children of the keys but if you want to it's easy to go from say, cosmosDb
-> resourceGroup -> securityGroups ...etc:
query {
queryazureCosmosDb {
id
name
type
kind
subscriptionId
region
resourceGroupId
provisioningState
documentEndpoint
databaseAccountOfferType
createdBy
createdByType
createdAt
lastModifiedBy
lastModifiedByType
lastModifiedAt
isVirtualNetworkFilterEnabled
enableAutomaticFailover
enableMultipleWriteLocations
enableCassandraConnector
connectorOffer
disableKeyBasedMetadataWriteAccess
keyVaultKeyUri
defaultIdentity
publicNetworkAccess
enableFreeTier
apiServerVersion
enableAnalyticalStorage
analyticalStorageConfigurationSchemaType
instanceId
createMode
networkAclBypass
networkAclBypassResourceIds
disableLocalAuth
capacityTotalThroughputLimit
tags {
id
key
value
}
identity {
principalId
type
tenantId
userAssignedIdentities {
id
key
value {
principalId
clientId
}
}
userAssignedIdentitiesAggregate {
count
idMin
idMax
keyMin
keyMax
}
}
ipRules {
id
ipAddressOrRange
}
consistencyPolicy {
defaultConsistencyLevel
maxStalenessPrefix
maxIntervalInSeconds
}
capabilities {
id
name
}
writeLocations {
id
locationName
documentEndpoint
provisioningState
failoverPriority
isZoneRedundant
}
readLocations {
id
locationName
documentEndpoint
provisioningState
failoverPriority
isZoneRedundant
}
locations {
id
locationName
documentEndpoint
provisioningState
failoverPriority
isZoneRedundant
}
failoverPolicies {
id
locationName
failoverPriority
}
virtualNetworkRules {
id
ignoreMissingVNetServiceEndpoint
}
privateEndpointConnections {
id
name
type
privateEndpointId
privateLinkServiceConnectionState {
status
description
actionsRequired
}
groupId
provisioningState
}
restoreParameters {
restoreMode
restoreSource
restoreTimestampInUtc
databasesToRestore {
id
databaseName
collectionNames
}
databasesToRestoreAggregate {
count
idMin
idMax
databaseNameMin
databaseNameMax
}
}
backupPolicy {
type
migrationState {
status
targetType
startTime
}
periodicModeProperties {
backupIntervalInMinutes
backupRetentionIntervalInHours
backupStorageRedundancy
}
}
cors {
id
allowedOrigins
allowedMethods
allowedHeaders
exposedHeaders
maxAgeInSeconds
}
databases {
id
name
type
options {
throughput
maxThroughput
}
resource {
id
rid
ts
etag
}
data {
id
name
type
}
}
azureTables {
id
name
type
options {
throughput
maxThroughput
}
resource {
id
rid
ts
etag
}
}
resourceGroup {
id
name
type
kind
subscriptionId
region
managedBy
disks {
id
}
dns {
id
}
firewalls {
id
}
functionApps {
id
}
keyVaults {
id
}
networkInterfaces {
id
}
publicIps {
id
}
securityGroups {
id
}
storageAccounts {
id
}
storageContainers {
id
}
virtualMachines {
id
}
virtualNetworks {
id
}
tags{
id
key
value
}
}
}
}