# 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](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/integrate-cloud-billing/broken-reference) in your GCP project.
2. Create a service account with [BigQuery Data Viewer](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/integrate-cloud-billing/broken-reference) 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](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/connecting-azure-cost-management#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 %}
