You can create an autoscale setting on a VM to use host-level metrics, or metrics based on a guest operating system.
For a list of supported metrics, see Azure Monitor autoscaling common metrics.
For a full sample for Virtual Machine Scale Sets, see Advanced autoscale configuration by using Resource Manager templates for Virtual Machine Scale Sets.
The sample uses the host-level CPU metric and a message count metric.