|
| 1 | +--- |
| 2 | +title: How to restrict the virtual machine sizes allowed for labs |
| 3 | +description: Learn how to use the Lab Services should restrict allowed virtual machine SKU sizes Azure Policy to restrict educators to specified virtual machine sizes for their labs. |
| 4 | +ms.topic: how-to |
| 5 | +ms.author: rosemalcolm |
| 6 | +author: RoseHJM |
| 7 | +ms.date: 08/23/2022 |
| 8 | +--- |
| 9 | + |
| 10 | +# How to restrict the virtual machine sizes allowed for labs |
| 11 | + |
| 12 | +In this how to, you'll learn how to use the *Lab Services should restrict allowed virtual machine SKU sizes* Azure policy to control the SKUs available to educators when they're creating labs. In this example, you'll see how a lab administrator can allow only non-GPU SKUs, so educators can create only non-GPU SKU labs. |
| 13 | + |
| 14 | +[!INCLUDE [lab plans only note](./includes/lab-services-new-update-focused-article.md)] |
| 15 | + |
| 16 | +## Configure the policy |
| 17 | + |
| 18 | +1. In the [Azure portal](https://portal.azure.com), go to your subscription. |
| 19 | + |
| 20 | +1. From the left menu, under **Settings**, select **Policies**. |
| 21 | + |
| 22 | +1. Under **Authoring**, select **Assignments**. |
| 23 | + |
| 24 | +1. Select **Assign Policy**. |
| 25 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy.png" alt-text="Screenshot showing the Policy Compliance dashboard with Assign policy highlighted."::: |
| 26 | + |
| 27 | +1. Select the **Scope** which you would like to assign the policy to, and then select **Select**. |
| 28 | + You can also select a resource group if you need the policy to apply more granularly. |
| 29 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-basics-scope.png" alt-text="Screenshot showing the Scope pane with subscription highlighted."::: |
| 30 | + |
| 31 | +1. Select Policy Definition. In Available definitions, search for *Lab Services*, select **Lab Services should restrict allowed virtual machine SKU sizes** and then select **Select**. |
| 32 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-basics-definitions.png" alt-text="Screenshot showing the Available definitions pane with Lab Services should restrict allowed virtual machine SKU sizes highlighted. "::: |
| 33 | + |
| 34 | +1. On the Basics tab, select **Next**. |
| 35 | + |
| 36 | +1. On the Parameters tab, clear **Only show parameters that need input or review** to show all parameters. |
| 37 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-parameters.png" alt-text="Screenshot showing the Parameters tab with Only show parameters that need input or review highlighted. "::: |
| 38 | + |
| 39 | +1. The **Allowed SKU names** parameter shows the SKUs allowed when the policy is applied. By default all the available SKUs are allowed. You must clear the check boxes for any SKU that you don't wish to allow educators to use to create labs. In this example, only the following non-GPU SKUs are allowed: |
| 40 | + - CLASSIC_FSV2_2_4GB_128_S_SSD |
| 41 | + - CLASSIC_FSV2_4_8GB_128_S_SSD |
| 42 | + - CLASSIC_FSV2_8_16GB_128_S_SSD |
| 43 | + - CLASSIC_DSV4_4_16GB_128_P_SSD |
| 44 | + - CLASSIC_DSV4_8_32GB_128_P_SSD |
| 45 | + |
| 46 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-parameters-vms.png" alt-text="Screenshot showing the Allowed SKUs."::: |
| 47 | + |
| 48 | + Use the table below to determine which SKU names to apply. |
| 49 | + |
| 50 | + |SKU Name|VM Size|VM Size Details| |
| 51 | + |-----|-----|-----| |
| 52 | + |CLASSIC_FSV2_2_4GB_128_S_SSD| Small |2vCPUs, 4 GB RAM, 128 GB, Standard SSD |
| 53 | + |CLASSIC_FSV2_4_8GB_128_S_SSD| Medium |4vCPUs, 8 GB RAM, 128 GB, Standard SSD |
| 54 | + |CLASSIC_FSV2_8_16GB_128_S_SSD| Large |8vCPUs, 16 GB RAM, 128 GB, Standard SSD |
| 55 | + |CLASSIC_DSV4_4_16GB_128_P_SSD| Medium (Nested virtualization) |4 vCPUs, 16 GB RAM, 128 GB, Premium SSD |
| 56 | + |CLASSIC_DSV4_8_32GB_128_P_SSD| Large (Nested virtualization) |8vCPUs, 32 GB RAM, 128 GB, Premium SSD |
| 57 | + |CLASSIC_NCSV3_6_112GB_128_S_SSD| Small GPU (Compute) |6vCPUs, 112 GB RAM, 128 GB, Standard SSD |
| 58 | + |CLASSIC_NVV4_8_28GB_128_S_SSD| Small GPU (Visualization) |8vCPUs, 28 GB RAM, 128 GB, Standard SSD |
| 59 | + |CLASSIC_NVV3_12_112GB_128_S_SSD| Medium GPU (Visualization) |12vCPUs, 112 GB RAM, 128 GB, Standard SSD |
| 60 | + |
| 61 | +1. In **Effect**, select **Deny**. Selecting deny will prevent a lab from being created if an educator tries to use a GPU SKU. |
| 62 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-parameters-effect.png" alt-text="Screenshot showing the effect list."::: |
| 63 | + |
| 64 | +1. Select **Next**. |
| 65 | + |
| 66 | +1. On the Remediation tab, select **Next**. |
| 67 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-remediation.png" alt-text="Screenshot showing the Remediation tab with Next highlighted."::: |
| 68 | + |
| 69 | +1. On the Non-compliance tab, in **Non-compliance messages**, enter a non-compliance message of your choice like “Selected SKU is not allowed”, and then select **Next**. |
| 70 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-message.png" alt-text="Screenshot showing the Non-compliance tab with an example non-compliance message."::: |
| 71 | + |
| 72 | +1. On the Review + Create tab, select **Create** to create the policy assignment. |
| 73 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-review-create.png" alt-text="Screenshot showing the Review and Create tab."::: |
| 74 | + |
| 75 | +You've created a policy assignment for *Lab Services should restrict allowed virtual machine SKU sizes* and allowed only the use of non-GPU SKUs for labs. Attempting to create a lab with any other SKU will fail. |
| 76 | + |
| 77 | +> [!NOTE] |
| 78 | +> New policy assignments can take up to 30 minutes to take effect. |
| 79 | +
|
| 80 | +## Exclude resources |
| 81 | + |
| 82 | +When applying a built-in policy, you can choose to exclude certain resources, with the exception of lab plans. For example, if the scope of your policy assignment is a subscription, you can exclude resources in a specified resource group. Exclusions are configured using the Exclusions property on the Basics tab when creating a policy definition. |
| 83 | + |
| 84 | +:::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-basics-exclusions.png" alt-text="Screenshot showing the Basics tab with Exclusions highlighted."::: |
| 85 | + |
| 86 | + |
| 87 | +## Exclude a lab plan |
| 88 | + |
| 89 | +Lab plans cannot be excluded using the Exclusions property on the Basics tab. To exclude a lab plan from a policy assignment, you first need to get the lab plan resource ID, and then use it to specify the lab pan you want to exclude on the Parameters tab. |
| 90 | + |
| 91 | +### Locate and copy lab plan resource ID |
| 92 | +Use the following steps to locate and copy the resource ID so that you can paste it into the exclusion configuration. |
| 93 | +1. In the [Azure portal](https://portal.azure.com), go to the lab plan you want to exclude. |
| 94 | + |
| 95 | +1. Under Settings, select Properties, and then copy the **Resource ID**. |
| 96 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/resource-id.png" alt-text="Screenshot showing the lab plan properties with resource ID highlighted."::: |
| 97 | + |
| 98 | +### Enter the lab plan to exclude in the policy |
| 99 | +Now you have a lab plan resource ID, you can use it to exclude the lab plan as you assign the policy. |
| 100 | +1. On the Parameters tab, clear **Only show parameters that need input or review**. |
| 101 | +1. For **Lab Plan ID to exclude**, enter the lab plan resource ID you copied earlier. |
| 102 | + :::image type="content" source="./media/how-to-use-restrict-allowed-virtual-machine-sku-sizes-policy/assign-policy-exclude-lab-plan-id.png" alt-text="Screenshot showing the Parameter tab with Lab Plan ID to exclude highlighted."::: |
| 103 | + |
| 104 | + |
| 105 | +## Next steps |
| 106 | +See the following articles: |
| 107 | +- [What’s new with Azure Policy for Lab Services?](azure-polices-for-lab-services.md) |
| 108 | +- [Built-in Policies](/azure/governance/policy/samples/built-in-policies#lab-services) |
| 109 | +- [What is Azure policy?](/azure/governance/policy/overview) |
| 110 | + |
0 commit comments