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

NameDatatypeDescription
idtextAzure Resource Manager Id for the rule. This is a read ony value.
nametextName of the rule. This is a read only value.
descriptiontextfield from the properties object
billingAccountIdtextfield from the properties object
created_datetextfield from the properties object
detailstextfield from the properties object
ruleNametextfield from the properties object
statustextfield from the properties object
typetextResource type of the rule. This is a read only value of Microsoft.CostManagement/CostAllocationRule.
updated_datetextfield from the properties object

Methods

NameAccessible byRequired 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

SELECT examples

Get the list of all cost allocation rules for a billing account or enterprise enrollment.

SELECT
id,
name,
description,
billingAccountId,
created_date,
details,
ruleName,
status,
type,
updated_date
FROM azure.cost_management.vw_cost_allocation_rules
WHERE billingAccountId = '{{ billingAccountId }}';

INSERT example

Use the following StackQL query and manifest file to create a new cost_allocation_rules resource.

/*+ create */
INSERT INTO azure.cost_management.cost_allocation_rules (
billingAccountId,
ruleName,
properties
)
SELECT
'{{ billingAccountId }}',
'{{ ruleName }}',
'{{ properties }}'
;

DELETE example

Deletes the specified cost_allocation_rules resource.

/*+ delete */
DELETE FROM azure.cost_management.cost_allocation_rules
WHERE billingAccountId = '{{ billingAccountId }}'
AND ruleName = '{{ ruleName }}';