Skip to main content

cost_allocation_rules

Creates, updates, deletes, gets or lists a cost_allocation_rules resource.

Overview

Namecost_allocation_rules
TypeResource
Idazure.cost_management.cost_allocation_rules

Fields

The following fields are returned by SELECT queries:

OK. The request has succeeded.

NameDatatypeDescription
idstringAzure Resource Manager Id for the rule. This is a read ony value.
namestringName of the rule. This is a read only value.
propertiesobjectCost allocation rule properties
typestringResource type of the rule. This is a read only value of Microsoft.CostManagement/CostAllocationRule.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectbillingAccountId, ruleNameGet a cost allocation rule by rule name and billing account or enterprise enrollment.
listselectbillingAccountIdGet the list of all cost allocation rules for a billing account or enterprise enrollment.
create_or_updateinsertbillingAccountId, ruleNameCreate/Update a rule to allocate cost between different resources within a billing account or enterprise enrollment.
deletedeletebillingAccountId, ruleNameDelete cost allocation rule for billing account or enterprise enrollment.
check_name_availabilityexecbillingAccountIdChecks availability and correctness of a name for a cost allocation rule

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

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

SELECT examples

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

SELECT
id,
name,
properties,
type
FROM azure.cost_management.cost_allocation_rules
WHERE billingAccountId = '{{ billingAccountId }}' -- required
AND ruleName = '{{ ruleName }}' -- required
;

INSERT examples

Create/Update a rule to allocate cost between different resources within a billing account or enterprise enrollment.

INSERT INTO azure.cost_management.cost_allocation_rules (
data__properties,
billingAccountId,
ruleName
)
SELECT
'{{ properties }}',
'{{ billingAccountId }}',
'{{ ruleName }}'
RETURNING
id,
name,
properties,
type
;

DELETE examples

Delete cost allocation rule for billing account or enterprise enrollment.

DELETE FROM azure.cost_management.cost_allocation_rules
WHERE billingAccountId = '{{ billingAccountId }}' --required
AND ruleName = '{{ ruleName }}' --required
;

Lifecycle Methods

Checks availability and correctness of a name for a cost allocation rule

EXEC azure.cost_management.cost_allocation_rules.check_name_availability 
@billingAccountId='{{ billingAccountId }}' --required
@@json=
'{
"name": "{{ name }}",
"type": "{{ type }}"
}'
;