azure.vm
Virtual Machine Resource
- example:
Stop all running VMs
policies:
- name: stop-running-vms
resource: azure.vm
filters:
- type: instance-view
key: statuses[].code
op: in
value_type: swap
value: PowerState/running
actions:
- type: stop
- example:
Start all VMs
policies:
- name: start-vms
resource: azure.vm
actions:
- type: start
- example:
Restart all VMs
policies:
- name: start-vms
resource: azure.vm
actions:
- type: restart
- example:
Resize specific VM by name
policies:
- name: resize-vm
resource: azure.vm
filters:
- type: value
key: name
op: eq
value_type: normalize
value: fake_vm_name
actions:
- type: resize
vmSize: Standard_A2_v2
- example:
Delete specific VM by name
policies:
- name: delete-vm
resource: azure.vm
filters:
- type: value
key: name
op: eq
value_type: normalize
value: fake_vm_name
actions:
- type: delete
- example:
Find all VMs with a Public IP address
policies:
- name: vms-with-public-ip
resource: azure.vm
filters:
- type: network-interface
key: 'properties.ipConfigurations[].properties.publicIPAddress.id'
value: not-null
- example:
This policy will find all VMs that have Percentage CPU usage >= 75% over the last 72 hours
policies:
- name: busy-vms
resource: azure.vm
filters:
- type: metric
metric: Percentage CPU
op: ge
aggregation: average
threshold: 75
timeframe: 72
- example:
This policy will find all VMs that have Percentage CPU usage <= 1% over the last 72 hours, mark for deletion in 7 days
policies:
- name: delete-unused-vms
resource: azure.vm
filters:
- type: metric
metric: Percentage CPU
op: le
aggregation: average
threshold: 1
timeframe: 72
actions:
- type: mark-for-op
op: delete
days: 7
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'
network-interface
Actions
poweroff
Parent base class for filters and actions.
resize
Change a VM’s size
- example:
Resize specific VM by name
policies:
- name: resize-vm
resource: azure.vm
filters:
- type: value
key: name
op: eq
value_type: normalize
value: fake_vm_name
actions:
- type: resize
vmSize: Standard_A2_v2
restart
Parent base class for filters and actions.
start
Parent base class for filters and actions.
stop
Parent base class for filters and actions.