New-AzDisk
Create a new managed disk or snapshot in Azure.
Syntax
New-AzDisk
[-ResourceGroupName] <String>
[-DiskName] <String>
[-Location] <String>
[-Disk <PSDisk>]
[-DiskSizeGB] <Int32>
[-Sku] <PSDiskSku>
[-CreationData] <CreationData>
[-Tag] <Hashtable>
[-Zone] <String[]>
[-HyperVGeneration] <String>
[-OsType] <String>
[-EncryptionSettings] <EncryptionSettingsCollection>
[-NetworkAccessPolicy] <String>
[-ImageReferenceId] <String>
[]
Parameters
| Parameter | Type | Description |
|---|---|---|
| -ResourceGroupName | String | Name of the resource group. |
| -DiskName | String | Name of the new disk. |
| -Location | String | Azure region, e.g., "eastus". |
| -DiskSizeGB | Int32 | Size of the disk in GB. |
| -Sku | PSDiskSku | SKU of the disk (Standard_LRS, Premium_LRS, etc.). |
| -CreationData | CreationData | Source for the disk (empty, snapshot, image). |
| -Tag | Hashtable | Custom tags as key/value pairs. |
| -Zone | String[] | Availability zones. |
| -HyperVGeneration | String | Hyper-V generation (V1, V2). |
| -OsType | String | Operating system type (Windows, Linux). |
| -EncryptionSettings | EncryptionSettingsCollection | Encryption configuration. |
| -NetworkAccessPolicy | String | Network access policy (AllowAll, DenyAll, etc.). |
| -ImageReferenceId | String | Resource ID of an image to use as source. |
Examples
Example 1: Create a 128 GB Premium SSD Disk
New-AzDisk -ResourceGroupName "myRG" `
-DiskName "myDataDisk" `
-Location "eastus" `
-DiskSizeGB 128 `
-Sku @{Name="Premium_LRS"} `
-CreationData @{CreateOption="Empty"}
Example 2: Create a Disk from an Existing Snapshot
$snapshot = Get-AzSnapshot -ResourceGroupName "myRG" -SnapshotName "mySnapshot"
New-AzDisk -ResourceGroupName "myRG" `
-DiskName "diskFromSnapshot" `
-Location "eastus" `
-CreationData @{CreateOption="Copy"; SourceResourceId=$snapshot.Id} `
-Sku @{Name="StandardSSD_LRS"}