Introduction
You may manage which VM sizes can be installed in your environment using Azure Policy, as well as which sizes are prohibited by omission. This Deny policy will prevent VMs from being created with or resized to any instance that is not stated in your policy. The instance sizes are known as SKUs (stock keeping units).
This article demonstrates how to set up allowed virtual machine size SKUs policy that restricts the deployment of your virtual machines based on Standard_B20ms and Standard_B2ms sizes only.
Step 1
Go to your subscription and select Policies under Settings.
Step 2
Go to Assign policy under Assignments.
Step 3
Select the correct scope.
In Policy definitions, search for Allowed virtual machine size SKUs.
Step 4
You can provide a Description if you want. Then click on Next button.
Step 5
In the Parameters tab, select the desired sizes and click on Next button.
Step 6
You can add a Non-compliance message under Non-compliance messages tab. Then click on Review + create.
Step 7
Click on Create button. You will be able to see the created policy in the list.
Step 8
After adding the policy, when you are trying to create a VM you will see a notification like below:
When you try to select a size for your VM, you will be displayed a list of available sizes and a list od sized blocked by the policy. You won’t be able to select the sized under Blocked by Policy list.
Summary
In this article, you learned how to implement an allowed virtual machine size SKUs policy in Azure. Please use the comments section if you have any clarification.