Cloud

Query Azure

Query Azure subscriptions, compute instances, storage, and networking with cnquery

Mondoo's azure provider lets you use cnquery to query and inventory your Azure resources. You can explore subscriptions, compute instances, storage accounts, databases, networking, and more.

Requirements

To analyze your Azure environment with cnquery, you must have:

Configure access to Azure

Log into Azure using the Azure CLI:

az login

To verify access, run a quick query from your terminal:

cnquery run azure -c 'azure.resources'

Connect to Azure

To query the default subscription:

cnquery shell azure

To query a specific subscription:

cnquery shell azure --subscription SUBSCRIPTION_ID

Example queries

Storage accounts

List all storage accounts in the subscription:

cnquery> azure.subscription.storage.accounts
azure.subscription.storage.accounts: [
  0: azure.subscription.storageService.account name="prodbackups"
  1: azure.subscription.storageService.account name="appdata"
  ...
]

Retrieve details about storage accounts:

cnquery> azure.subscription.storage.accounts { id type properties }
azure.subscription.storage.accounts: [
  0: {
    id: "/subscriptions/xxx/resourceGroups/prod/providers/Microsoft.Storage/storageAccounts/prodbackups"
    type: "Microsoft.Storage/storageAccounts"
    properties: {
      provisioningState: "Succeeded"
      primaryLocation: "eastus"
      statusOfPrimary: "available"
    }
  }
  ...
]

Filter storage accounts by kind:

cnquery> azure.subscription.storage.accounts.where(kind == "BlobStorage") { id name type }
azure.subscription.storage.accounts.where: [
  0: {
    id: "/subscriptions/xxx/resourceGroups/prod/providers/Microsoft.Storage/storageAccounts/archiveblobs"
    name: "archiveblobs"
    type: "Microsoft.Storage/storageAccounts"
  }
]

Request full details

For a detailed report on any resource, specify that you want all fields:

cnquery> azure.subscription.storage.accounts { * }

Learn more

On this page