Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Analyze and reduce Azure cloud costs by right-sizing resources, reservations, and spending policies
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
cost-query/dimensions-by-scope.md
1# Dimensions by Scope23Dimension availability matrix for the Cost Management Query API, organized by scope type and agreement type.45## Scope URL Patterns67| Scope | URL Pattern |8|-------|-------------|9| Subscription | `/subscriptions/<subscription-id>` |10| Resource Group | `/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>` |11| Management Group | `/providers/Microsoft.Management/managementGroups/<management-group-id>` |12| Billing Account | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>` |13| Billing Profile | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/billingProfiles/<billing-profile-id>` |14| Invoice Section | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/billingProfiles/<billing-profile-id>/invoiceSections/<invoice-section-id>` |15| Department (EA) | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/departments/<department-id>` |16| Enrollment Account (EA) | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/enrollmentAccounts/<enrollment-account-id>` |17| Customer (Partner) | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/customers/<customer-id>` |1819## Common Dimensions2021The following dimensions are available across most scopes:2223> ⚠️ **Warning:** `ResourceId` grouping is **only supported at subscription and resource group scopes**. At higher scopes (billing account, management group, billing profile, etc.), use `ServiceName`, `SubscriptionName`, or another supported dimension instead. See [guardrails.md](guardrails.md) for the full scope restriction table.2425| Dimension | Description |26|-----------|-------------|27| `ResourceGroupName` | Resource group containing the resource. |28| `ResourceId` | Full Azure resource ID. |29| `ResourceLocation` | Azure region where the resource is deployed. |30| `ServiceName` | Azure service name (e.g., Virtual Machines, Storage). |31| `ServiceFamily` | Service family grouping (e.g., Compute, Storage, Networking). |32| `ServiceTier` | Service tier or SKU tier (e.g., Standard, Premium). |33| `MeterCategory` | Top-level meter classification. |34| `MeterSubCategory` | Meter sub-classification. |35| `Meter` | Specific meter name. |36| `ChargeType` | Type of charge (e.g., Usage, Purchase, Refund). |37| `PublisherType` | Publisher type (e.g., Azure, Marketplace, AWS). |38| `PricingModel` | Pricing model (e.g., OnDemand, Reservation, SavingsPlan, Spot). |39| `SubscriptionName` | Subscription display name. |40| `SubscriptionId` | Subscription GUID. |41| `TagKey` | Azure resource tag key (use with `TagKey` column type in grouping). |42| `Product` | Product name from the price sheet. |43| `BenefitName` | Reservation or savings plan name. |44| `BillingPeriod` | Billing period identifier. |4546## Scope-Specific Dimensions4748Additional dimensions available only at certain scopes:4950| Scope | Additional Dimensions |51|-------|-----------------------|52| Subscription | _(common dimensions only)_ |53| Resource Group | _(common dimensions only)_ |54| Management Group | `DepartmentName`, `EnrollmentAccountName` |55| Billing Account | `BillingProfileName`, `DepartmentName`, `EnrollmentAccountName`, `InvoiceSectionName`, `Customer` |56| Billing Profile | `InvoiceSectionName`, `Customer` |57| Invoice Section | _(common dimensions only)_ |58| Department (EA) | `EnrollmentAccountName` |59| Enrollment Account (EA) | _(common dimensions only)_ |60| Customer (Partner) | _(common dimensions only)_ |6162## Agreement Type Dimension Sets6364Available dimensions vary by agreement type. Only dimensions listed for your agreement type are valid in GroupBy and Filter expressions.6566### EA (Enterprise Agreement)6768| Dimension | Available |69|-----------|-----------|70| `ResourceGroupName` | ✅ |71| `ResourceId` | ✅ ⚠️ |72| `SubscriptionName` | ✅ |73| `Product` | ✅ |74| `ResourceLocation` | ✅ |75| `ServiceName` | ✅ |76| `ServiceFamily` | ✅ |77| `TagKey` | ✅ |78| `MeterSubCategory` | ✅ |79| `PublisherType` | ✅ |80| `PricingModel` | ✅ |81| `ChargeType` | ✅ |82| `ServiceTier` | ✅ |83| `BenefitName` | ✅ |84| `BillingProfileName` | ✅ |85| `DepartmentName` | ✅ |86| `EnrollmentAccountName` | ✅ |87| `BillingPeriod` | ✅ |8889### MCA (Microsoft Customer Agreement)9091| Dimension | Available |92|-----------|-----------|93| `ResourceGroupName` | ✅ |94| `ResourceId` | ✅ ⚠️ |95| `SubscriptionName` | ✅ |96| `Product` | ✅ |97| `ResourceLocation` | ✅ |98| `ServiceName` | ✅ |99| `ServiceFamily` | ✅ |100| `TagKey` | ✅ |101| `MeterSubCategory` | ✅ |102| `PublisherType` | ✅ |103| `PricingModel` | ✅ |104| `ChargeType` | ✅ |105| `ServiceTier` | ✅ |106| `BenefitName` | ✅ |107| `BillingProfileName` | ✅ |108| `InvoiceSectionName` | ✅ |109110### MOSP (Microsoft Online Services Program / Pay-As-You-Go)111112| Dimension | Available |113|-----------|-----------|114| `ResourceGroupName` | ✅ |115| `ResourceId` | ✅ ⚠️ |116| `SubscriptionName` | ✅ |117| `Product` | ✅ |118| `ResourceLocation` | ✅ |119| `ServiceName` | ✅ |120| `ServiceFamily` | ✅ |121| `TagKey` | ✅ |122| `MeterSubCategory` | ✅ |123| `PublisherType` | ✅ |124| `PricingModel` | ✅ |125| `ChargeType` | ✅ |126| `ServiceTier` | ✅ |127| `BenefitName` | ✅ |128129> ⚠️ `ResourceId` is available as a dimension but **only works in GroupBy at subscription and resource group scopes**. At billing account or management group scopes, use `ServiceName` or `SubscriptionName` instead.130131### Comparison Summary132133| Dimension | EA | MCA | MOSP |134|-----------|----|----|------|135| `ResourceGroupName` | ✅ | ✅ | ✅ |136| `ResourceId` | ✅ ⚠️ | ✅ ⚠️ | ✅ ⚠️ |137| `SubscriptionName` | ✅ | ✅ | ✅ |138| `Product` | ✅ | ✅ | ✅ |139| `ResourceLocation` | ✅ | ✅ | ✅ |140| `ServiceName` | ✅ | ✅ | ✅ |141| `ServiceFamily` | ✅ | ✅ | ✅ |142| `TagKey` | ✅ | ✅ | ✅ |143| `MeterSubCategory` | ✅ | ✅ | ✅ |144| `PublisherType` | ✅ | ✅ | ✅ |145| `PricingModel` | ✅ | ✅ | ✅ |146| `ChargeType` | ✅ | ✅ | ✅ |147| `ServiceTier` | ✅ | ✅ | ✅ |148| `BenefitName` | ✅ | ✅ | ✅ |149| `BillingProfileName` | ✅ | ✅ | ❌ |150| `DepartmentName` | ✅ | ❌ | ❌ |151| `EnrollmentAccountName` | ✅ | ❌ | ❌ |152| `InvoiceSectionName` | ❌ | ✅ | ❌ |153| `BillingPeriod` | ✅ | ❌ | ❌ |154155## Scope Resolution Priority156157When multiple scope identifiers are available in context, use the following priority order (highest first):158159| Priority | Scope | Notes |160|----------|-------|-------|161| 1 | Management Group | Broadest organizational scope. |162| 2 | Resource Group | Narrowest resource scope. |163| 3 | Subscription | Default scope for most queries. |164| 4 | Billing Profile + Invoice Section | MCA billing hierarchy. |165| 5 | Billing Profile | MCA billing scope. |166| 6 | Department | EA organizational unit. |167| 7 | Enrollment Account | EA enrollment scope. |168| 8 | Customer | Partner/CSP customer scope. |169| 9 | Invoice Section | Standalone invoice section. |170| 10 | Billing Account | Top-level billing scope. |171172> 💡 **Tip:** When a user provides both a subscription and a resource group, prefer the Resource Group scope (priority 2) over Subscription (priority 3) for more targeted results.173174## Required Context Variables175176The following context variables are needed to resolve scope and validate dimensions:177178| Variable | Description | Used For |179|----------|-------------|----------|180| `AgreementType` | The agreement type (`EA`, `MCA`, `MOSP`). | Determines valid dimension set. |181| `AccountType` | Account type within the agreement. | Refines scope-specific behavior. |182| `CallScopeId` | The fully qualified scope URL for the API call. | Builds the request URL path. |183