Gregory Suvalian
Gregory Suvalian

Reputation: 3830

How do I change "OSType" of managed disk in Azure?

I have a managed disk which contains OS but which is not marked as having operating system (OSType property is empty). How do I change that property so I can create new VM from within portal?

PS Azure:\> $disk


ResourceGroupName  : KoreaCentralShared
ManagedBy          :
Sku                : Microsoft.Azure.Management.Compute.Models.DiskSku
Zones              :
TimeCreated        : 12/18/18 9:45:26 PM
OsType             :
CreationData       : Microsoft.Azure.Management.Compute.Models.CreationData
DiskSizeGB         : 80
EncryptionSettings :
ProvisioningState  : Succeeded
DiskIOPSReadWrite  :
DiskMBpsReadWrite  :
Id                 : /subscriptions/5171/resourceGroups/K/providers/Microsoft.Compute/disks/RHEL_DataDisk_0
Name               : RHEL_DataDisk_0
Type               : Microsoft.Compute/disks
Location           : koreacentral
Tags               : {}

Upvotes: 0

Views: 2270

Answers (1)

Hannel
Hannel

Reputation: 1706

You should be able to update the OsType using commands below.

Example:

$update = New-AzureRmDiskUpdateConfig -OsType <OSType> Update-AzureRmDisk -DiskName <diskname> -DiskUpdate $update -ResourceGroupName <rgname>

Personally i would copy the Disk to a new disk and specify the osType on new disk creation

Example:

$managedDisk = Get-AzureRmDisk -DiskName <diskname> -ResourceGroupName <rgname> $diskConfig = New-AzureRmDiskConfig -SourceResourceId $managedDisk.Id -Location $managedDisk.Location -CreateOption Copy -OsType Linux New-AzureRmDisk -Disk $diskConfig -DiskName <Newdiskname> -ResourceGroupName <rgname>

https://learn.microsoft.com/en-us/azure/virtual-machines/scripts/virtual-machines-windows-powershell-sample-copy-managed-disks-to-same-or-different-subscription

Hope this helps.

Upvotes: 1

Related Questions