Share via

ARM template set OS disk networking

Luke Rosser 165 Reputation points
2026-02-17T14:53:23.43+00:00

I'm trying to disable public network access on an OS disk for a VM using ARM. I am selecting the image using publisher, offer, sku and version when the VM is created. I can't see any way to configure networking on the disk when creating it as part of the VM definition, and I am unable to update the disk after it is created by the VM.

What I have tried:

  • Creating the disk through the VM resource and setting networking on the VM OS disk definition (not supported)
  • Creating the disk before the VM and attaching it as the OS disk (publisher, offer, sku and version aren't supported)
  • Letting the VM create the disk and updating it with ARM in the same template or with a nested template (conflicts/expects it to be a creation and asks for more info)

When attempting to update the OS disk after the VM creates it through this code:


        {
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "2025-04-01",
            "name": "os-disk-networking",
            "dependsOn": [
                "[resourceId('Microsoft.Compute/virtualMachines', variables('vm_name'))]"
            ],
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "resources": [
                        {
                            "type": "Microsoft.Compute/disks",
                            "apiVersion": "2025-01-02",
                            "name": "[concat(variables('vm_name'), '-osdisk')]",
                            "location": "[parameters('location')]",
                            "properties": {
                                "networkAccessPolicy": "DenyAll",
                                "publicNetworkAccess": "Disabled"
                            }
                        }
                    ]
                }
            }
        }


I get an error:

Required parameter 'creationData' is missing (null). (Code: InvalidParameter, Target: creationData)

The disk name matches the name given to the OS disk in the VM definition:

                    "osDisk": {
                        "osType": "Windows",
                        "name": "[concat(variables('vm_name'), '-osdisk')]",
                        "createOption": "FromImage",
                        "caching": "ReadWrite",
                        "managedDisk": {
                            "storageAccountType": "StandardSSD_LRS"
                        },
                        "deleteOption": "Detach",
                        "diskSizeGB": "[parameters('vm_os_disk_size')]"
                    }
Azure Disk Storage
Azure Disk Storage

A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.

0 comments No comments
{count} votes

Answer accepted by question author
  1. Ankit Yadav 12,205 Reputation points Microsoft External Staff Moderator
    2026-02-19T04:08:20.23+00:00

    Hello @Luke Rosser

    I've made some changes to the template as below and this worked out for me pretty well to update the Network settings for OS disk of an existing VM.

    Kindly test this out and let us know if this also fails for you.

    {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "diskName": {
          "type": "String",
          "metadata": {
            "description": "Name of the existing disk"
          }
        },
        "location": {
          "type": "String",
          "metadata": {
            "description": "Location of the disk (e.g., 'eastus')"
          }
        },
        "osType": {
          "type": "String",
          "metadata": {
            "description": "OS type (e.g., 'Linux')"
          }
        },
        "hyperVGeneration": {
          "type": "String",
          "metadata": {
            "description": "HyperV generation (e.g., 'V2')"
          }
        },
        "diskSizeGB": {
          "type": "int",
          "metadata": {
            "description": "Disk size in GB (e.g., 30)"
          }
        },
        "publicNetworkAccess": {
          "type": "String",
          "allowedValues": ["Enabled", "Disabled"]
        },
        "networkAccessPolicy": {
          "type": "String",
          "allowedValues": ["AllowAll", "AllowPrivate", "DenyAll"],
          "defaultValue": "DenyAll"
        },
        "dataAccessAuthMode": {
          "type": "String",
          "defaultValue": "None",
          "allowedValues": ["None", "AzureActiveDirectory"]
        },
        "imageReference": {
          "type": "object",
          "metadata": {
            "description": "Image reference from disk's creationData"
          }
        }
      },
      "resources": [
        {
          "type": "Microsoft.Compute/disks",
          "apiVersion": "2025-01-02",
          "name": "[parameters('diskName')]",
          "location": "[parameters('location')]",
          "sku": {
            "name": "Premium_LRS"
          },
          "properties": {
            "osType": "[parameters('osType')]",
            "hyperVGeneration": "[parameters('hyperVGeneration')]",
            "creationData": {
              "createOption": "FromImage",
              "imageReference": "[parameters('imageReference')]"
            },
            "diskSizeGB": "[parameters('diskSizeGB')]",
            "encryption": {
              "type": "EncryptionAtRestWithPlatformKey"
            },
            "publicNetworkAccess": "[parameters('publicNetworkAccess')]",
            "networkAccessPolicy": "[parameters('networkAccessPolicy')]",
            "dataAccessAuthMode": "[parameters('dataAccessAuthMode')]"
          }
        }
      ]
    }
    

2 additional answers

Sort by: Most helpful
  1. Marcin Policht 82,360 Reputation points MVP Volunteer Moderator
    2026-02-17T15:38:52.13+00:00

    Try creating the OS disk first, then in a separate ARM deployment (or a separate step after the VM is deployed), update the disk’s networking properties. The update template should include only the updatable properties:

    {
    

    Do not include creationData, diskSizeGB, sku, or any creation-related fields. This should ensure ARM performs a PATCH on the existing OS disk instead of trying to create a new disk.

    If you prefer CLI, the same update can be done with:

    az disk update --name <disk-name> --resource-group <resource-group> --set networkAccessPolicy=DenyAll publicNetworkAccess=Disabled
    

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    1 person found this answer helpful.

  2. Tim Gilroy 0 Reputation points
    2026-02-18T10:50:45.3466667+00:00

    Might not be helpful, but in similar situation using Bicep I determined the best option was to utilise a Runbook every evening.

    It works fine and answers the problem. Obviously we could use other methods to get the runbook fired by a deployment event.

    Regards

    $Disks = Get-AzDisk | Where-Object { 
        $_.PublicNetworkAccess -eq 'Enabled'
        } 
        Foreach ($disk in $Disks) { 
            Write-OutPut "Disk $($disk) has network access enabled.  Disabling ..."
            try {
            $disk | New-AzDiskUpdateConfig -PublicNetworkAccess "Disabled" -NetworkAccessPolicy "DenyAll" `
            | Update-AzDisk -ResourceGroupName $($disk.ResourceGroupName) -DiskName $($disk.Name) 
            Write-OutPut "Disk Updated with Deny Network Access Policy"
            } catch {
                Write-OutPut "Runbook Failed to update Disk.  Please investigate."
            }
    }
    

Your answer

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