cost_allocation_rules
Creates, updates, deletes, gets or lists a cost_allocation_rules resource.
Overview
| Name | cost_allocation_rules |
| Type | Resource |
| Id | azure.cost_management.cost_allocation_rules |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
id | string | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. |
name | string | The name of the resource. |
createdDate | string (date-time) | 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 | object | Resource information for the cost allocation rule. Required. |
status | string | Status of the rule. Required. Known values are: "NotActive", "Active", and "Processing". (NotActive, Active, Processing) |
systemData | object | Azure Resource Manager metadata containing createdBy and modifiedBy information. |
type | string | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". |
updatedDate | string (date-time) | Time at which the rule was last updated. |
| Name | Datatype | Description |
|---|---|---|
id | string | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. |
name | string | The name of the resource. |
createdDate | string (date-time) | 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 | object | Resource information for the cost allocation rule. Required. |
status | string | Status of the rule. Required. Known values are: "NotActive", "Active", and "Processing". (NotActive, Active, Processing) |
systemData | object | Azure Resource Manager metadata containing createdBy and modifiedBy information. |
type | string | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". |
updatedDate | string (date-time) | Time at which the rule was last updated. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | billing_account_id, rule_name | Get a cost allocation rule by rule name and billing account or enterprise enrollment. | |
list | select | billing_account_id | Get the list of all cost allocation rules for a billing account or enterprise enrollment. | |
create_or_update | insert | billing_account_id, rule_name | Create/Update a rule to allocate cost between different resources within a billing account or enterprise enrollment. | |
create_or_update | replace | billing_account_id, rule_name | Create/Update a rule to allocate cost between different resources within a billing account or enterprise enrollment. | |
delete | delete | billing_account_id, rule_name | Delete cost allocation rule for billing account or enterprise enrollment. | |
check_name_availability | exec | billing_account_id | Checks 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.
| Name | Datatype | Description |
|---|---|---|
billing_account_id | string | BillingAccount ID. Required. |
rule_name | string | Cost 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
- list
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
;
Get the list of all cost allocation rules for a 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
;
INSERT examples
- create_or_update
- Manifest
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
;
# Description fields are for documentation purposes
- name: cost_allocation_rules
props:
- name: billing_account_id
value: "{{ billing_account_id }}"
description: Required parameter for the cost_allocation_rules resource.
- name: rule_name
value: "{{ rule_name }}"
description: Required parameter for the cost_allocation_rules resource.
- name: properties
description: |
Cost allocation rule properties.
value:
description: "{{ description }}"
details:
sourceResources:
- resourceType: "{{ resourceType }}"
name: "{{ name }}"
values: "{{ values }}"
targetResources:
- resourceType: "{{ resourceType }}"
name: "{{ name }}"
values: "{{ values }}"
policyType: "{{ policyType }}"
status: "{{ status }}"
createdDate: "{{ createdDate }}"
updatedDate: "{{ updatedDate }}"
REPLACE examples
- create_or_update
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
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
- check_name_availability
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 }}"
}'
;