Creating VM with out denying public IP policy

Varma 1,495 Reputation points
2024-02-09T07:10:25.3166667+00:00

While running packer build, we are ending up following error ,"policyExemptionIds":[]},"type":"PolicyViolation"}],"code":"RequestDisallowedByPolicy","message":"Resource 'pkrnihhqzm20za7' was disallowed by policy. Reasons: 'this is not a permissions error. you are trying to create a VM with an public IP this is denied by policy, if it is something you need please reach out to techops'. See error details for policy resource 'pkrvmhhqzm20za7' was disallowed by policy. Policy identifiers: but we want to proceed further and make VM to be created even public IP set to none how it is possible?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,014 questions
0 comments No comments
{count} votes

Accepted answer
  1. Martin Therkelsen 1,410 Reputation points MVP
    2024-02-09T17:30:33.78+00:00

    Hi Varma, You have two options here. Either you exempt your packer resource group from the deny public IP policy or use an existing vNet and execute the packer build from a VM in this vNet.

    If you want to exempt the resource group you can read the post by Emily here: https://www.seb8iaan.com/create-an-exemption-rule-to-exclude-a-resource-from-a-security-recommendation/

    The packer JSON can use these lines to use an existing vNet.

    	"virtual_network_name": "packerpoc",
    	"virtual_network_resource_group_name" : "packerpoc",
    	"virtual_network_subnet_name" : "packerpoc",
    

1 additional answer

Sort by: Most helpful
  1. Sam Cogan 10,812 Reputation points Microsoft Employee Volunteer Moderator
    2024-02-09T08:49:14.34+00:00

    You need to amend your Packer build scripts to create a VM without a public IP; however, to do this, the machine you are running Packer on will need to be on the same vNet as the VM so that it can talk to it with a private IP. If you just remove the public IP without doing that, packer will fail because it cannot connect to the VM.

    1 person found this answer helpful.

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.