azure.cost-management-scheduled-action
Cost Management Scheduled Actions for current subscription (doesn’t include Resource Group, Billing Account, or other scopes).
A scheduled action of kind InsightAlert is Azure’s cost anomaly
alert: it compares current spend against a baseline Cost Management
learns from the scope’s own history. Other kinds (for example
Email) mail cost analysis data on a schedule and carry no baseline.
- example:
Returns all cost management scheduled actions for current subscription scope
policies:
- name: get-cost-management-scheduled-actions
resource: azure.cost-management-scheduled-action
- example:
Find anomaly alerts that are disabled, run on a cadence other than daily, or carry no notification recipients
policies:
- name: find-unhealthy-cost-anomaly-alerts
resource: azure.cost-management-scheduled-action
filters:
- type: value
key: kind
value: InsightAlert
- or:
- type: value
key: properties.status
op: ne
value: Enabled
- type: value
key: properties.schedule.frequency
op: ne
value: Daily
- type: value
key: properties.notification.to
value: absent
Filters
advisor-recommendation
Filter resources by Azure Advisor Recommendations
Select all categories with ‘all’
- example:
policies:
- name: disks-with-cost-recommendations
resource: azure.disk
filters:
- type: advisor-recommendation
category: Cost
key: '[].properties.recommendationTypeId'
op: contains
value: '48eda464-1485-4dcf-a674-d0905df5054a'
properties:
category:
type: string
default:
type: object
key:
type: string
op:
enum:
- eq
- equal
- ne
- not-equal
- gt
- greater-than
- ge
- gte
- le
- lte
- lt
- less-than
- glob
- regex
- regex-case
- in
- ni
- not-in
- contains
- difference
- intersect
- mod
tag_key_transforms:
items:
type: string
type: array
type:
enum:
- advisor-recommendation
value:
oneOf:
- type: array
- type: string
- type: boolean
- type: number
- type: 'null'
value_from:
additionalProperties: 'False'
properties:
expr:
oneOf:
- type: integer
- type: string
format:
enum:
- csv
- json
- txt
- csv2dict
headers:
patternProperties:
? ''
: type: string
type: object
query:
type: string
url:
type: string
required:
- url
type: object
value_path:
type: string
value_regex:
type: string
value_type:
enum:
- age
- integer
- expiration
- normalize
- size
- cidr
- cidr_size
- swap
- resource_count
- expr
- unique_size
- date
- version
- float
- duration
required:
- category
- type
Actions
set-status
Set the status of a Cost Management scheduled action (for example an
InsightAlert anomaly alert) to Enabled or Disabled.
ScheduledActionsOperations.create_or_update_by_scope has the same upstream SDK bug as list_by_scope (see CostManagementScheduledActionSource.get_resources): it serializes its scope path parameter without skip_quote=True, percent-encoding the ‘/’ characters and producing a malformed request. This bypasses the typed operation and PUTs directly to the same subscription-scoped URL get_resources lists from - resource[‘id’] isn’t used because the API doesn’t consistently return it with a leading slash.
- example:
Enable disabled anomaly alerts
policies:
- name: enable-cost-anomaly-alerts
resource: azure.cost-management-scheduled-action
filters:
- type: value
key: kind
value: InsightAlert
- type: value
key: properties.status
op: ne
value: Enabled
actions:
- type: set-status
status: Enabled
properties:
status:
enum:
- Enabled
- Disabled
type: string
type:
enum:
- set-status
required:
- status
- type
Permissions - Microsoft.CostManagement/scheduledActions/write