Setting up an Azure Integration
CloudQuery Platform authenticates with Azure either through workload identity federation, which stores no credentials, or through a service principal secret. Both use the Reader role.
Workload identity federation is the recommended method: CloudQuery authenticates to your Entra ID tenant with a short-lived token, so there is no secret to store or rotate. Use a service principal secret if you cannot run the setup script.
Prerequisites
- A CloudQuery Platform account with admin access
- Azure CLI installed
- An Azure account with permissions to create app registrations (or service principals) and assign roles
- Your Azure subscription ID (find it in the Azure Portal subscriptions page)
Set up authentication
Choose one of the two methods below. Workload identity federation is recommended; the service principal secret flow follows it.
Option A: Workload identity federation
CloudQuery generates an az CLI script that creates an app registration, adds a federated identity credential pinned to your CloudQuery tenant alone, and assigns the Reader role. No secret is created, so there is nothing to store or rotate.
You need the Azure CLI and permission to create app registrations and assign roles in the tenant.
- In CloudQuery Platform, go to Data Sources → Integrations. Click Add new integration and type Azure to find the Azure integration.
- Under Choose authentication method, select Workload identity federation.

-
Click Generate setup script.
-
Copy the generated script and run it in a terminal logged in to the tenant you want CloudQuery to read:
az login -
The script prints two values when it finishes. Paste them back into CloudQuery:
- Azure AD Tenant ID
- Application (client) ID
-
Click Complete setup. There is no separate verification step — Entra ID enforces the exact issuer, subject, and audience match natively, so the Test and Continue token exchange in Configure the integration is the verification.
-
The script assigns Reader only on the scope it targeted. To sync a wider set of subscriptions, grant Reader to the app registration at the management group or subscription scope you need.
Role assignments and federated credentials take a short time to propagate in Entra ID. If the connection test fails immediately after running the script with a permission or authentication error, wait a moment and click Test and Continue again before changing anything.
Continue at Configure the integration.
Option B: Service principal secret
Service principal secrets expire after 1 year by default. Set a calendar reminder to rotate the secret before it expires, or use the --years flag with az ad sp create-for-rbac to set a custom expiration.
Syncing from a single subscription
- Open your terminal and log in to Azure:
az login- Register the security provider and create a service principal with Reader access:
# Register the security provider
az provider register --namespace 'Microsoft.Security'
# Create a service principal and grant Reader access
az ad sp create-for-rbac --name cloudquery-sp \
--scopes /subscriptions/<YOUR_SUBSCRIPTION_ID> --role ReaderThe command outputs credentials in this format:
{
"appId": "YOUR_AZURE_CLIENT_ID",
"displayName": "cloudquery-sp",
"password": "YOUR_AZURE_CLIENT_SECRET",
"tenant": "YOUR_AZURE_TENANT_ID"
}- Save these credentials; you need them when configuring the integration.
Syncing from multiple subscriptions
There are two approaches for multi-subscription setups:
1. Management group level access (recommended)
Scoping the service principal at the management group level allows automatic discovery of all subscriptions under the specified group(s), including subscriptions added later.
# Register the security provider
az provider register --namespace 'Microsoft.Security'
# Create service principal with Management Group access
az ad sp create-for-rbac --name cloudquery-sp-root-1 \
--scopes /providers/Microsoft.Management/managementGroups/<YOUR_MANAGEMENT_GROUP_NAME> \
--role Reader2. Specific subscriptions access
To limit access to specific subscriptions, list them explicitly. This command grants access to all subscriptions you can currently access:
# Register the security provider
az provider register --namespace 'Microsoft.Security'
# Create service principal with access to specific subscriptions
az ad sp create-for-rbac --name cloudquery-sp \
--scopes $(az account subscription list --query "[].id" -o tsv --only-show-errors | xargs) \
--role ReaderWith the specific subscriptions approach, the service principal does not automatically get access to subscriptions added later. Run the command again to include new subscriptions.
Configure the integration
- In the CloudQuery Platform sidebar, under Data Sources, click Integrations, then click Add new integration. On the New integration page, type Azure in the search field and click the Azure card.

-
Enter an Integration name (e.g.
Azure), then set up authentication:- If you used workload identity federation (Option A), you already entered the tenant and client IDs during setup, so there is nothing to paste here. The connection is verified when you click Test and Continue below.
- If you used a service principal secret (Option B), keep Service principal secret selected under Choose authentication method, then enter the service principal credentials in the fields provided:
Field Value Azure AD Tenant ID tenantfrom the service principal outputService Principal App ID appIdfrom the service principal outputService Principal Password passwordfrom the service principal output -
Under Configure resources to sync, choose which subscriptions to include or exclude.
-
Click Continue to select the Azure services you want to sync.
-
Click Test and Continue to verify the configuration.
What gets synced
The Azure integration can sync hundreds of tables across Azure services. Some of the most commonly used tables include:
| Category | Tables | Description |
|---|---|---|
| Compute | azure_compute_virtual_machines, azure_compute_skus | VMs, compute SKUs |
| Storage | azure_storage_accounts | Storage accounts |
| Networking | azure_network_virtual_networks, azure_network_security_groups | Virtual networks, network security groups |
| Databases | azure_sql_servers, azure_cosmosdb_accounts | SQL servers, Cosmos DB |
| Security | azure_keyvault_vault_keys, azure_security_assessments | Key Vault keys, security assessments |
See the full Azure table list for all available tables.
Verify the integration
After your first sync completes, open the SQL Console and run these queries to confirm data arrived:
-- Count synced virtual machines
SELECT count(*) FROM azure_compute_virtual_machines-- List synced subscriptions
SELECT DISTINCT subscription_id FROM azure_compute_virtual_machines-- View storage accounts
SELECT subscription_id, name, location FROM azure_storage_accounts LIMIT 10You can also browse your Azure resources in the Asset Inventory under the Compute, Storage, Networking, and other categories.
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Authentication error | Invalid or expired service principal secret | Verify the AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID match the service principal output. If the secret has expired, create a new one. |
| Permission denied | Service principal lacks Reader role | Verify the service principal has the Reader role on the target subscription, management group, or resource group. |
Microsoft.Security provider not registered | Security provider registration required | Run az provider register --namespace 'Microsoft.Security' and wait for registration to complete. Check status with az provider show --namespace 'Microsoft.Security' --query "registrationState". |
| Missing subscriptions in data | Service principal scope too narrow | For multi-subscription setups, verify the service principal has access to all target subscriptions. Use management group scoping for automatic discovery. |
| No data after sync | No services selected | Check that at least one service is selected in the Select services step. |
| Connection test fails right after running the setup script | Federated credential or role assignment has not propagated | Wait a few minutes and click Test and Continue again. Entra ID takes a short time to apply a new federated identity credential and role assignment. |
| Permission denied with workload identity federation | Reader not granted at the wanted scope | The setup script assigns Reader only on the scope it targeted. Grant Reader to the app registration at the management group or subscription scope you want to sync. |
Next steps
- Set up a sync to schedule when your Azure data is fetched
- Browse synced resources in the Asset Inventory
- Run advanced queries in the SQL Console
- See the Azure integration documentation for full configuration options and table reference
Related resources
- Microsoft Entra Workload Identity Federation
- Azure CLI installation guide
- Azure Service Principal tutorial
- Azure Management Groups overview
- Azure RBAC built-in roles
- Azure resource providers and types
- CloudQuery Azure integration on Hub
Last updated on