如何更改 Azure 中托管磁盘的 "OSType"?

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

我有一个托管磁盘,其中包含 OS 但未标记为具有操作系统(OSType 属性 为空)。如何更改 属性 以便我可以在门户中创建新的 VM?

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               : {}

您应该能够使用以下命令更新 OsType。

示例:

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

我个人会将磁盘复制到新磁盘并在创建新磁盘时指定 osType

示例:

$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://docs.microsoft.com/en-us/azure/virtual-machines/scripts/virtual-machines-windows-powershell-sample-copy-managed-disks-to-same-or-different-subscription

希望对您有所帮助。