Cost Allocation Rules - List
Get the list of all cost allocation rules for a billing account or enterprise enrollment.
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules?api-version=2023-11-01
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
billing
|
path | True |
string |
BillingAccount ID |
api-version
|
query | True |
string |
The API version to use for this operation. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
List of cost allocation rules for the billing account or enterprise enrollment. |
|
Other Status Codes |
Error response describing why the operation failed |
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name | Description |
---|---|
user_impersonation | impersonate your user account |
Examples
CostAllocationRulesList
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules?api-version=2023-11-01
Sample response
{
"value": [
{
"id": "providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule",
"name": "testRule",
"type": "Microsoft.CostManagement/costAllocationRules",
"properties": {
"description": "This is a testRule",
"createdDate": "2020-06-18T22:21:51.1287144Z",
"updatedDate": "2020-06-18T22:21:51.1287144Z",
"status": "NotActive",
"details": {
"sourceResources": [
{
"resourceType": "Dimension",
"name": "ResourceGroupName",
"values": [
"sampleRG"
]
}
],
"targetResources": [
{
"resourceType": "Dimension",
"policyType": "FixedProportion",
"name": "ResourceGroupName",
"values": [
{
"name": "destinationRG",
"percentage": 50
},
{
"name": "destinationRG2",
"percentage": 50
}
]
}
]
}
}
},
{
"id": "providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule2",
"name": "testRule2",
"type": "Microsoft.CostManagement/costAllocationRules",
"properties": {
"description": "This is a second test Rule",
"createdDate": "2020-06-18T22:21:51.1287144Z",
"updatedDate": "2020-06-18T22:21:51.1287144Z",
"status": "Active",
"details": {
"sourceResources": [
{
"resourceType": "Dimension",
"name": "SubscriptionId",
"values": [
"2A002F2D-536F-4D7C-90DA-3D0BAE879B0E"
]
}
],
"targetResources": [
{
"resourceType": "Tag",
"policyType": "FixedProportion",
"name": "category",
"values": [
{
"name": "devops",
"percentage": 100
}
]
}
]
}
}
},
{
"id": "providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule3",
"name": "testRule3",
"type": "Microsoft.CostManagement/costAllocationRules",
"properties": {
"description": "This is a third test Rule",
"createdDate": "2020-06-18T22:21:51.1287144Z",
"updatedDate": "2020-06-18T22:21:51.1287144Z",
"status": "Active",
"details": {
"sourceResources": [
{
"resourceType": "Tag",
"name": "category",
"values": [
"devops"
]
}
],
"targetResources": [
{
"resourceType": "Dimension",
"policyType": "FixedProportion",
"name": "ResourceGroupName",
"values": [
{
"name": "ResourceGroup",
"percentage": 55.55
},
{
"name": "ResourceGroupSecond",
"percentage": 44.45
}
]
}
]
}
}
}
],
"nextLink": null
}
Definitions
Name | Description |
---|---|
Cost |
Method to use for allocating cost. FixedProportion indicates that cost will be split based on specified percentage values. |
Cost |
Target resources and allocation |
Cost |
Category of resource to use for allocation. |
Cost |
The cost allocation rule model definition |
Cost |
Resource details of the cost allocation rule |
Cost |
Result of listing cost allocation rules. It contains a list of available rules in the billing account or enterprise enrollment provided. |
Cost |
The properties of a cost allocation rule |
Error |
The details of the error. |
Error |
Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. Some Error responses:
|
Rule |
Current status of the rule. |
Source |
Source resources for cost allocation |
Target |
Target resources for cost allocation. |
CostAllocationPolicyType
Method to use for allocating cost. FixedProportion indicates that cost will be split based on specified percentage values.
Name | Type | Description |
---|---|---|
FixedProportion |
string |
CostAllocationProportion
Target resources and allocation
Name | Type | Description |
---|---|---|
name |
string |
Target resource for cost allocation |
percentage |
number |
Percentage of source cost to allocate to this resource. This value can be specified to two decimal places and the total percentage of all resources in this rule must sum to 100.00. |
CostAllocationResourceType
Category of resource to use for allocation.
Name | Type | Description |
---|---|---|
Dimension |
string |
Indicates an Azure dimension such as a subscription id or resource group name is being used for allocation. |
Tag |
string |
Allocates cost based on Azure Tag key value pairs. |
CostAllocationRuleDefinition
The cost allocation rule model definition
Name | Type | Description |
---|---|---|
id |
string |
Azure Resource Manager Id for the rule. This is a read ony value. |
name |
string |
Name of the rule. This is a read only value. |
properties |
Cost allocation rule properties |
|
type |
string |
Resource type of the rule. This is a read only value of Microsoft.CostManagement/CostAllocationRule. |
CostAllocationRuleDetails
Resource details of the cost allocation rule
Name | Type | Description |
---|---|---|
sourceResources |
Source resources for cost allocation. At this time, this list can contain no more than one element. |
|
targetResources |
Target resources for cost allocation. At this time, this list can contain no more than one element. |
CostAllocationRuleList
Result of listing cost allocation rules. It contains a list of available rules in the billing account or enterprise enrollment provided.
Name | Type | Description |
---|---|---|
nextLink |
string |
URL to get the next set of rule list results if there are any. |
value |
The list of cost allocation rules. |
CostAllocationRuleProperties
The properties of a cost allocation rule
Name | Type | Description |
---|---|---|
createdDate |
string |
Time at which the rule was created. Rules that change cost for the same resource are applied in order of creation. |
description |
string |
Description of a cost allocation rule. |
details |
Resource information for the cost allocation rule |
|
status |
Status of the rule |
|
updatedDate |
string |
Time at which the rule was last updated. |
ErrorDetails
The details of the error.
Name | Type | Description |
---|---|---|
code |
string |
Error code. |
message |
string |
Error message indicating why the operation failed. |
ErrorResponse
Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message.
Some Error responses:
429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header.
503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header.
Name | Type | Description |
---|---|---|
error |
The details of the error. |
RuleStatus
Current status of the rule.
Name | Type | Description |
---|---|---|
Active |
string |
Rule is saved and impacting cost allocation. |
NotActive |
string |
Rule is saved but not used to allocate costs. |
Processing |
string |
Rule is saved and cost allocation is being updated. Readonly value that cannot be submitted in a put request. |
SourceCostAllocationResource
Source resources for cost allocation
Name | Type | Description |
---|---|---|
name |
string |
If resource type is dimension, this must be either ResourceGroupName or SubscriptionId. If resource type is tag, this must be a valid Azure tag |
resourceType |
Type of resources contained in this cost allocation rule |
|
values |
string[] |
Source Resources for cost allocation. This list cannot contain more than 25 values. |
TargetCostAllocationResource
Target resources for cost allocation.
Name | Type | Description |
---|---|---|
name |
string |
If resource type is dimension, this must be either ResourceGroupName or SubscriptionId. If resource type is tag, this must be a valid Azure tag |
policyType |
Method of cost allocation for the rule |
|
resourceType |
Type of resources contained in this cost allocation rule |
|
values |
Target resources for cost allocation. This list cannot contain more than 25 values. |