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:
- cnquery installed on your workstation
- An Azure subscription
- The Azure CLI installed
Configure access to Azure
Log into Azure using the Azure CLI:
az loginTo 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 azureTo query a specific subscription:
cnquery shell azure --subscription SUBSCRIPTION_IDExample 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
-
To learn more about how the MQL query language works, read Write Effective MQL.
-
For a list of all the Azure resources and fields you can query, read the Azure Resource Pack Reference.