我想调整我的操作系统磁盘空间,但得到“仅在创建 VM 或解除分配 VM 时才允许调整磁盘大小”。
Microsoft.Azure.Management.ResourceManager.Fluent.Core.RestClient restClient = GetRestClient(requestObject);
var computeClient = new ComputeManagementClient(restClient) { SubscriptionId = requestObject.SubscriptionId };
var ObjVirtualMachines = computeClient.VirtualMachines.GetAsync(requestObject.ResourceGroupName, requestObject.VirtualMachineName, null, new System.Threading.CancellationToken()).Result;
var disktodetach = ObjVirtualMachines.StorageProfile.OsDisk;
ObjVirtualMachines.StorageProfile.OsDisk.DiskSizeGB = requestObject.DiskSize;
var newUpdateVM = computeClient.VirtualMachines.CreateOrUpdateAsync(requestObject.ResourceGroupName, requestObject.VirtualMachineName, ObjVirtualMachines).Result;
resizeDisk = newUpdateVM.ProvisioningState;