> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/azure-billing.md).

# Azure Billing

Read Azure cost and usage from Cost Management and the Consumption API. Break spend down by service, resource group, location, meter or tag, forecast future cost, track budgets, and drill into individual usage lines.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector     | Authentication |
| ------------- | -------------- |
| Azure Billing | Credentials    |

#### Azure Billing

Read Azure cost, usage and budgets with an Entra ID service principal holding the Cost Management Reader role.

**Set up in Azure Billing**

1. Prepare the Azure Billing account or service that the workflow will access. Grant access to the required resources and operations.
2. Obtain the account, endpoint, and authentication values listed below from the service administrator.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Azure Billing**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field | Required | What to enter                                                                                                                                                                                                                                                                                              |
| ------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Tenant ID     | Yes      | The Entra ID tenant (directory) the service principal belongs to. [Provider instructions](https://learn.microsoft.com/entra/fundamentals/how-to-find-tenant).                                                                                                                                              |
| Client ID     | Yes      | Application (client) ID of the app registration. Grant its service principal the 'Cost Management Reader' role on the subscription, management group or billing account you want to read. [Provider instructions](https://learn.microsoft.com/azure/cost-management-billing/costs/assign-access-acm-data). |
| Client Secret | Yes      | A client secret for the app registration. [Provider instructions](https://learn.microsoft.com/entra/identity-platform/quickstart-register-app).                                                                                                                                                            |

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **Azure Billing** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Query Cost

Read Azure spend for a date range, optionally broken down by service, resource group, location, meter or tag.

**Inputs**

| Field         | Type            | Required | Description                                                                                                                                                                                                                                                                                       |
| ------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Scope         | select (string) | Yes      | Which subscription or billing account to report on. A bare subscription ID is accepted. Options load from the selected connection.                                                                                                                                                                |
| Date Range    | select (string) | No       | Pick a preset window, or choose 'custom' and set Start Date and End Date. month\_to\_date and last\_month are CALENDAR months; the billing\_ presets follow your enrolment's billing period, which can differ on EA and MCA. Options load from the selected connection. Default: month\_to\_date. |
| Start Date    | string          | No       | First day to include (YYYY-MM-DD). Needed for 'custom'.                                                                                                                                                                                                                                           |
| End Date      | string          | No       | Last day to include (YYYY-MM-DD). This day is included. Needed for 'custom'.                                                                                                                                                                                                                      |
| Cost Type     | select (string) | No       | ActualCost is what was invoiced. AmortizedCost spreads reservation and savings-plan fees across their term. Options load from the selected connection. Default: ActualCost.                                                                                                                       |
| Granularity   | select (string) | No       | Size of each time bucket. 'None' returns one total for the period. Options load from the selected connection. Default: Daily.                                                                                                                                                                     |
| Metric        | select (string) | No       | Which figure to aggregate. Options load from the selected connection. Default: Cost.                                                                                                                                                                                                              |
| Group By Type | select (string) | No       | Break the results down by a dimension or by a tag key. Options load from the selected connection.                                                                                                                                                                                                 |
| Group By      | select (string) | No       | What to group by: a dimension such as ServiceName or ResourceGroup, or one of your tag keys. Options load from the selected connection.                                                                                                                                                           |
| Filter Type   | select (string) | No       | Restrict the query to one dimension value or tag value. Options load from the selected connection.                                                                                                                                                                                                |
| Filter Name   | select (string) | No       | The dimension or tag key to filter on. Options load from the selected connection.                                                                                                                                                                                                                 |
| Filter Values | string          | No       | Keep only these values. Separate several with commas.                                                                                                                                                                                                                                             |
| Maximum Pages | integer         | No       | How many result pages to fetch before stopping.                                                                                                                                                                                                                                                   |

**Outputs**

| Field        | Type    | Description                                                    |
| ------------ | ------- | -------------------------------------------------------------- |
| Rows         | array   | One row per bucket and grouping, with its amount and currency. |
| Total Amount | number  | The metric summed across every row.                            |
| Currency     | string  | Currency of the amounts, as reported by Azure.                 |
| Period       | string  | The window the query actually covered.                         |
| Truncated    | boolean | True when Azure had more pages than the page limit allowed.    |

#### Get Cost Forecast

Forecast what Azure will cost over a period, separating spend already billed from what is still predicted.

**Inputs**

| Field         | Type            | Required | Description                                                                                                                                                                                                                                                                                       |
| ------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Scope         | select (string) | Yes      | Which subscription or billing account to report on. A bare subscription ID is accepted. Options load from the selected connection.                                                                                                                                                                |
| Date Range    | select (string) | No       | Pick a preset window, or choose 'custom' and set Start Date and End Date. month\_to\_date and last\_month are CALENDAR months; the billing\_ presets follow your enrolment's billing period, which can differ on EA and MCA. Options load from the selected connection. Default: month\_to\_date. |
| Start Date    | string          | No       | First day to include (YYYY-MM-DD). Needed for 'custom'.                                                                                                                                                                                                                                           |
| End Date      | string          | No       | Last day to include (YYYY-MM-DD). This day is included. Needed for 'custom'.                                                                                                                                                                                                                      |
| Cost Type     | select (string) | No       | ActualCost is what was invoiced. AmortizedCost spreads reservation and savings-plan fees across their term. Options load from the selected connection. Default: ActualCost.                                                                                                                       |
| Granularity   | select (string) | No       | Size of each time bucket. 'None' returns one total for the period. Options load from the selected connection. Default: Daily.                                                                                                                                                                     |
| Metric        | select (string) | No       | Which cost figure to forecast. Options load from the selected connection. Default: Cost.                                                                                                                                                                                                          |
| Maximum Pages | integer         | No       | How many result pages to fetch before stopping.                                                                                                                                                                                                                                                   |

**Outputs**

| Field          | Type    | Description                                              |
| -------------- | ------- | -------------------------------------------------------- |
| Rows           | array   | One row per bucket, flagged as actual or predicted.      |
| Forecast Total | number  | Predicted spend only, excluding billed actuals.          |
| Actual Total   | number  | Spend already billed within the forecast window.         |
| Currency       | string  | Currency of the amounts, as reported by Azure.           |
| Period         | string  | The window the forecast covered.                         |
| Truncated      | boolean | True when more results were available than were fetched. |

#### Get Dimension Values

List the services, resource groups, locations or other dimension values present in your Azure cost data.

**Inputs**

| Field         | Type            | Required | Description                                                                                                                        |
| ------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Scope         | select (string) | Yes      | Which subscription or billing account to report on. A bare subscription ID is accepted. Options load from the selected connection. |
| Dimension     | select (string) | Yes      | Which dimension to list values for. Options load from the selected connection.                                                     |
| Maximum Pages | integer         | No       | How many result pages to fetch before stopping.                                                                                    |

**Outputs**

| Field       | Type    | Description                                              |
| ----------- | ------- | -------------------------------------------------------- |
| Values      | array   | Values recorded for the dimension in the period.         |
| Total Count | number  | Number of values returned.                               |
| Truncated   | boolean | True when more results were available than were fetched. |

#### List Budgets

List Azure budgets with their current and forecast spend, and counts of those over or heading over limit.

**Inputs**

| Field         | Type            | Required | Description                                                                                                                        |
| ------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Scope         | select (string) | Yes      | Which subscription or billing account to report on. A bare subscription ID is accepted. Options load from the selected connection. |
| Maximum Pages | integer         | No       | How many result pages to fetch before stopping.                                                                                    |

**Outputs**

| Field                      | Type    | Description                                                |
| -------------------------- | ------- | ---------------------------------------------------------- |
| Budgets                    | array   | Budgets on the scope with their limit, spend and forecast. |
| Over Budget Count          | number  | How many budgets have already exceeded their limit.        |
| Forecast Over Budget Count | number  | How many budgets are forecast to exceed their limit.       |
| Budget Count               | number  | Number of budgets returned.                                |
| Truncated                  | boolean | True when more results were available than were fetched.   |

#### List Usage Details

List individual Azure usage lines with their cost, meter and resource. Use a short date range: this is the most granular and highest volume data.

**Inputs**

| Field         | Type            | Required | Description                                                                                                                                                                 |
| ------------- | --------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Scope         | select (string) | Yes      | Which subscription or billing account to report on. A bare subscription ID is accepted. Options load from the selected connection.                                          |
| Cost Type     | select (string) | No       | ActualCost is what was invoiced. AmortizedCost spreads reservation and savings-plan fees across their term. Options load from the selected connection. Default: ActualCost. |
| Limit         | integer         | No       | How many of the most recent usage lines to return per page.                                                                                                                 |
| Maximum Pages | integer         | No       | How many result pages to fetch before stopping.                                                                                                                             |

**Outputs**

| Field      | Type    | Description                                                 |
| ---------- | ------- | ----------------------------------------------------------- |
| Details    | array   | Individual usage lines with their cost, meter and resource. |
| Total Cost | number  | Cost summed across every line returned.                     |
| Currency   | string  | Currency of the costs, as reported by Azure.                |
| Truncated  | boolean | True when Azure had more pages than the page limit allowed. |

#### List Subscriptions

List the Azure subscriptions your service principal can read.

**Inputs**

| Field         | Type    | Required | Description                                     |
| ------------- | ------- | -------- | ----------------------------------------------- |
| Maximum Pages | integer | No       | How many result pages to fetch before stopping. |

**Outputs**

| Field         | Type    | Description                                              |
| ------------- | ------- | -------------------------------------------------------- |
| Subscriptions | array   | Subscriptions the service principal can see.             |
| Total Count   | number  | Number of subscriptions returned.                        |
| Truncated     | boolean | True when more results were available than were fetched. |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/azure-billing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
