Azure policy to turn off public and private access to disk.

Nana Poku 180 Reputation points
2025-01-22T16:11:54.68+00:00

Can I get help with a azure policy to turn off public access to existing managed disks so that is not accessible to public internet.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,301 questions
{count} votes

Accepted answer
  1. Ashok Gandhi Kotnana 3,220 Reputation points Microsoft Vendor
    2025-01-22T16:54:11.05+00:00

    Hi @Nana Poku,

    Welcome to Microsoft Q&A Forum, thank you for posting your query here!

    Instead of using an Azure policy use Azure Automation account and schdule this job when ver it is required

    Can you use an automation Account and create a run book. This is very easy to use.

    Below script will do the job

    $disks = Get-AzDisk | Where-Object {$_.PublicNetworkAccess -eq 'Enabled'}
    foreach ($disk in $disks) {$disk | New-AzDiskUpdateConfig -PublicNetworkAccess "Disabled" -NetworkAccessPolicy "DenyAll" | Update-AzDisk -resourcegroup $($disk.resourcegroupname) -diskname $($disk.name)}
    

    Below is the artifact of the output:-

    User's image

    User's image

    Feel free to reach out if you have any further questions or need additional information—I’m happy to assist!

    Please provide your valuable comments User's image

    Please do not forget to "Accept the answer” and “upvote it” wherever the information provided helps you, this can be beneficial to other community members.it would be greatly appreciated and helpful to others.


0 additional answers

Sort by: Most 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.