Skip to Content

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.

  1. In CloudQuery Platform, go to Data SourcesIntegrations. Click Add new integration and type Azure to find the Azure integration.
  2. Under Choose authentication method, select Workload identity federation.

The Connect to Azure step with the Choose authentication method toggle set to Workload identity federation

  1. Click Generate setup script.

  2. Copy the generated script and run it in a terminal logged in to the tenant you want CloudQuery to read:

    az login
  3. The script prints two values when it finishes. Paste them back into CloudQuery:

    • Azure AD Tenant ID
    • Application (client) ID
  4. 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.

  5. 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

  1. Open your terminal and log in to Azure:
az login
  1. 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 Reader

The command outputs credentials in this format:

{ "appId": "YOUR_AZURE_CLIENT_ID", "displayName": "cloudquery-sp", "password": "YOUR_AZURE_CLIENT_SECRET", "tenant": "YOUR_AZURE_TENANT_ID" }
  1. 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 Reader

2. 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 Reader

With 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

  1. 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.

The New integration page with a search for Azure and the matching Azure card

  1. 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:
    FieldValue
    Azure AD Tenant IDtenant from the service principal output
    Service Principal App IDappId from the service principal output
    Service Principal Passwordpassword from the service principal output
  2. Under Configure resources to sync, choose which subscriptions to include or exclude.

  3. Click Continue to select the Azure services you want to sync.

  4. 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:

CategoryTablesDescription
Computeazure_compute_virtual_machines, azure_compute_skusVMs, compute SKUs
Storageazure_storage_accountsStorage accounts
Networkingazure_network_virtual_networks, azure_network_security_groupsVirtual networks, network security groups
Databasesazure_sql_servers, azure_cosmosdb_accountsSQL servers, Cosmos DB
Securityazure_keyvault_vault_keys, azure_security_assessmentsKey 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 10

You can also browse your Azure resources in the Asset Inventory under the Compute, Storage, Networking, and other categories.

Troubleshooting

IssueCauseFix
Authentication errorInvalid or expired service principal secretVerify 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 deniedService principal lacks Reader roleVerify the service principal has the Reader role on the target subscription, management group, or resource group.
Microsoft.Security provider not registeredSecurity provider registration requiredRun 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 dataService principal scope too narrowFor multi-subscription setups, verify the service principal has access to all target subscriptions. Use management group scoping for automatic discovery.
No data after syncNo services selectedCheck that at least one service is selected in the Select services step.
Connection test fails right after running the setup scriptFederated credential or role assignment has not propagatedWait 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 federationReader not granted at the wanted scopeThe 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

Was this page helpful?

Last updated on