Does, not allowed resource type "Microsoft.Network.virtualNetworks" stop me from creating a VM

Shridhar Srinivasan 220 Reputation points
2023-07-14T10:22:22.3+00:00

You have an Azure subscription named mySubscription. Under the subscription, you go ahead and create a resource group named myRG.
You then go ahead and create an Azure policy based on the “Not allowed resources types” definition. Here you define the parameters as Microsoft.Network.virtualNetworks as the not allowed resource type. You assign this policy to the top Management group "Tenant Root Group".
Would you be able to create a virtual machine in the myRG resource group?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,041 questions
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,526 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Prrudram-MSFT 25,881 Reputation points
    2023-07-20T16:16:04.17+00:00

    @Shridhar Srinivasan

    Your point "I think during a VM creation, a VNet and Network Interface (NIC) creation are mandatory. Because of the Policy, won't VM creation be stopped?" is correct. Any new VNet creation during the VM creation should fail in the RG that has restrictions.
    However, if there is any existing VNET available in the RG already that can be used to create the VM. In that way the VM creation shouldn't fail.

    If this does answer your question, please accept it as the answer as a token of appreciation.

    1 person found this answer helpful.

  2. Tech-Hyd-1989 5,796 Reputation points
    2023-07-14T10:29:02.86+00:00

    Hello Srinivasan, Shridhar (Shridhar)

    Yes, you would be able to create a virtual machine in the "myRG" resource group, even if the Azure policy you defined restricts the creation of "Microsoft.Network.virtualNetworks" resources.

    The Azure policy you created and assigned to the "Tenant Root Group" is focused on preventing the creation of virtual networks (Microsoft.Network.virtualNetworks), not virtual machines (Microsoft.Compute/virtualMachines). Therefore, you can still create virtual machines within the resource group "myRG" as long as they comply with the policy's restrictions on virtual networks.

    It's important to note that Azure policies are resource-level restrictions, and they don't block the creation of other resource types within the same resource group unless specifically defined in the policy.

    So, in this scenario, you can proceed with creating a virtual machine in the "myRG" resource group without any issues, as the policy only applies to virtual networks.


  3. Luckman 0 Reputation points
    2024-11-17T00:03:58.0433333+00:00

    I have tested this myself

    IF you are creating a VM and placing it into a NEW virtual network at (during the creation process), it will not work. This is because the policy ("Not allowed resources types”) blocks it.

    IF you are creating a VM and placing it into an EXISTING virtual network (during the creation process), it will work.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.