Exam: AZ-900: Microsoft Azure Fundamentals 0 Likes
You have a resource group named RG1. You plan to create virtual (AZ-900)
You have a resource group named RG1. You plan to create virtual networks and app services in RG1.
You need to prevent the creation of virtual machines only in RG1.
What should you use?
A) A lock.
B) An Azure role.
C) A tag.
D) An Azure policy.
Solution
Correct answer: D) An Azure policy.
Azure policies allow you to define and enforce rules for resources in your Azure subscription. You can create a policy that restricts the creation of virtual machines in a specific resource group, such as RG1.
Here's an example of how you can create a policy to prevent the creation of virtual machines in RG1:
Go to the Azure portal and navigate to the "Policies" section.
Click on "Create policy" and select "Custom policy".
In the "Policy definition" section, enter a name and description for the policy.
In the "Policy rule" section, select "Allowed resources" and enter the resource group name (RG1).
In the "Policy effect" section, select "Deny" and enter the resource type (Microsoft.Compute/virtualMachines).
Click "Create" to create the policy.
Once the policy is created, it will prevent any attempt to create a virtual machine in RG1.
A lock (A) is a mechanism that prevents accidental deletion or modification of a resource, but it does not prevent the creation of new resources.
An Azure role (B) is a set of permissions that defines what actions a user or service principal can perform on Azure resources. While you can create a custom role that restricts the creation of virtual machines, it is not the most efficient way to achieve this goal.
A tag (C) is a key-value pair that can be applied to Azure resources. While you can use tags to categorize and filter resources, they do not provide a way to enforce rules or restrictions on resource creation.
In summary, Azure policies are the recommended way to enforce rules and restrictions on resource creation in Azure.
Category: Azure management and governance