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:

NameDatatypeDescription
idstringFully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
namestringThe name of the resource.
createdDatestring (date-time)Time at which the rule was created. Rules that change cost for the same resource are applied in order of creation.
descriptionstringDescription of a cost allocation rule.
detailsobjectResource information for the cost allocation rule. Required.
statusstringStatus of the rule. Required. Known values are: "NotActive", "Active", and "Processing". (NotActive, Active, Processing)
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
updatedDatestring (date-time)Time at which the rule was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectbilling_account_id, rule_nameGet a cost allocation rule by rule name and billing account or enterprise enrollment.
listselectbilling_account_idGet the list of all cost allocation rules for a billing account or enterprise enrollment.
create_or_updateinsertbilling_account_id, rule_nameCreate/Update a rule to allocate cost between different resources within a billing account or enterprise enrollment.
create_or_updatereplacebilling_account_id, rule_nameCreate/Update a rule to allocate cost between different resources within a billing account or enterprise enrollment.
deletedeletebilling_account_id, rule_nameDelete cost allocation rule for billing account or enterprise enrollment.
check_name_availabilityexecbilling_account_idChecks 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
billing_account_idstringBillingAccount ID. Required.
rule_namestringCost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' and '-'. The max length is 260 characters. Required.

SELECT examples

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

SELECT
id,
name,
createdDate,
description,
details,
status,
systemData,
type,
updatedDate
FROM azure.cost_management.cost_allocation_rules
WHERE billing_account_id = '{{ billing_account_id }}' -- required
AND rule_name = '{{ rule_name }}' -- 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 (
properties,
billing_account_id,
rule_name
)
SELECT
'{{ properties }}',
'{{ billing_account_id }}',
'{{ rule_name }}'
RETURNING
id,
name,
properties,
systemData,
type
;

REPLACE examples

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

REPLACE azure.cost_management.cost_allocation_rules
SET
properties = '{{ properties }}'
WHERE
billing_account_id = '{{ billing_account_id }}' --required
AND rule_name = '{{ rule_name }}' --required
RETURNING
id,
name,
properties,
systemData,
type;

DELETE examples

Delete cost allocation rule for billing account or enterprise enrollment.

DELETE FROM azure.cost_management.cost_allocation_rules
WHERE billing_account_id = '{{ billing_account_id }}' --required
AND rule_name = '{{ rule_name }}' --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 
@billing_account_id='{{ billing_account_id }}' --required
@@json=
'{
"name": "{{ name }}",
"type": "{{ type }}"
}'
;