# Configuring multi-cloud billing integration

You can configure cloud billing integrations for multiple cloud providers using CRD. This allows PerfectScale to pull cost data directly from each source, taking into account your unique billing conditions, ensuring accurate pricing calculations for your multi-cloud environment.

In the following example, we’ll guide you through configuring cloud billing integrations for both GCP and Azure clusters.

## Step 1: Enable GCP Cloud Billing

1. Enable [BigQuery billing export](/cloud-billing-integration/connecting-gcp-cloud-billing.md#gcp-setup) in your GCP project.
2. Create a service account with [BigQuery Data Viewer](/cloud-billing-integration/connecting-gcp-cloud-billing.md#service-account-required-permissions) permissions.
3. Generate a JSON key for the service account.
4. Copy the service account details and billing configuration (you will need them for [CR configuration](#step-3-configure-cr)).

## Step 2: Enable Azure Cost Management

1. Set up Azure billing export in your subscription.
2. Create an Azure AD application and service principal.
3. Grant the application the [necessary permissions](#how-to-grant-permissions-to-your-application) to access billing data.
4. Generate a [client secret](#how-to-get-client_secret) for the application (if using client\_secret authentication).
5. Copy the [client ID](#how-to-get-client_id-and-tenant_id), [tenant ID](#how-to-get-client_id-and-tenant_id), [subscription ID](#how-to-get-client_subscription), and [client secret](#how-to-get-client_secret) to the configuration below.

## Step 3: Configure CR

```yaml
apiVersion: perfectscale.io/v1
kind: ClusterSettings
metadata:
  name: cluster-settings-main
  namespace: perfectscale
spec:
  profiles:
    pricing:
      # GCP Billing Export Integration
      - type: gcp_billing
        name: gcp-billing-export
        assigned: true
        value:
          global_discount:
            percentage: 4
            start_date: 2025-12-31
          gcp_billing_account: "your-gcp-billing-account-id"
          gcp_dataset_id: "billing_export_dataset"
          gcp_project_id: "my-gcp-project"
          gcp_service_account: "your-billing@my-project.iam.gserviceaccount.com"

      # Azure Billing Integration
      - type: azure_billing
        name: azure-billing-export
        assigned: false
        value:
          global_discount:
            percentage: 15
            start_date: 2025-12-31
          azure_auth_type: workload_identity
          azure_client_id: "your-azure-client-id-here"
          azure_subscription_id: "your-azure-subscription-id-here"
          azure_tenant_id: "your-azure-tenant-id-here"
```

{% hint style="info" %}
We recommend configuring a CR using `workload_identity` for `azure_auth_type`. However, alternatively, you can also configure a CR using `client_secret`. Learn more [here](/cloud-billing-integration/connecting-azure-cost-management.md#alternative-cr-configuration-not-recommended).
{% endhint %}

{% hint style="warning" %}
If a `global_discount` percentage is provided without a `start_date` in the CRD profile, we won’t default to today’s date as we do for profiles configured in the UI, and the discount will not be applied. The pricing profile appears broken in the UI.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.perfectscale.io/cloud-billing-integration/configuring-multi-cloud-billing-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
