Cost Allocation Rules - Get

Get a cost allocation rule by rule name and billing account or enterprise enrollment.

GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}?api-version=2024-08-01

URI Parameters

Name In Required Type Description
billingAccountId
path True

string

BillingAccount ID

ruleName
path True

string

Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' and '-'. The max length is 260 characters.

Regex pattern: [A-Za-z0-9\-_]+

api-version
query True

string

The API version to use for this operation.

Responses

Name Type Description
200 OK

CostAllocationRuleDefinition

OK. The request has succeeded.

Other Status Codes

ErrorResponse

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

CostAllocationRules

Sample request

GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule?api-version=2024-08-01

Sample response

{
  "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
            }
          ]
        }
      ]
    }
  }
}

Definitions

Name Description
CostAllocationPolicyType

Method to use for allocating cost. FixedProportion indicates that cost will be split based on specified percentage values.

CostAllocationProportion

Target resources and allocation

CostAllocationResourceType

Category of resource to use for allocation.

CostAllocationRuleDefinition

The cost allocation rule model definition

CostAllocationRuleDetails

Resource details of the cost allocation rule

CostAllocationRuleProperties

The properties of a cost allocation rule

ErrorDetails

The details of the error.

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.

RuleStatus

Current status of the rule.

SourceCostAllocationResource

Source resources for cost allocation

TargetCostAllocationResource

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

CostAllocationRuleProperties

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

SourceCostAllocationResource[]

Source resources for cost allocation. At this time, this list can contain no more than one element.

targetResources

TargetCostAllocationResource[]

Target resources for cost allocation. At this time, this list can contain no more than one element.

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

CostAllocationRuleDetails

Resource information for the cost allocation rule

status

RuleStatus

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

ErrorDetails

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

CostAllocationResourceType

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

CostAllocationPolicyType

Method of cost allocation for the rule

resourceType

CostAllocationResourceType

Type of resources contained in this cost allocation rule

values

CostAllocationProportion[]

Target resources for cost allocation. This list cannot contain more than 25 values.