public async Task Update() { var vmssName = Recording.GenerateAssetName("testVMSS-"); var vmss = await CreateVirtualMachineScaleSetAsync(vmssName); // Create a PPG here and add this PPG to this virtual machine using Update var ppgName = Recording.GenerateAssetName("testPPG-"); var ppgData = new ProximityPlacementGroupData(DefaultLocation) { }; var ppgLro = await _resourceGroup.GetProximityPlacementGroups().CreateOrUpdateAsync(WaitUntil.Completed, ppgName, ppgData); ProximityPlacementGroupResource ppg = ppgLro.Value; // update PPG requires the VM to be deallocated await vmss.DeallocateAsync(WaitUntil.Completed); var update = new VirtualMachineScaleSetPatch() { ProximityPlacementGroup = new WritableSubResource() { Id = ppg.Id } }; var lro = await vmss.UpdateAsync(WaitUntil.Completed, update); VirtualMachineScaleSetResource updatedVM = lro.Value; Assert.AreEqual(ppg.Id, updatedVM.Data.ProximityPlacementGroup.Id); }
public async Async.Task <OneFuzzResultVoid> ResizeVmss(Guid name, long capacity) { var canUpdate = await CheckCanUpdate(name); if (canUpdate.IsOk) { _log.Info($"updating VM count - name: {name} vm_count: {capacity}"); var scalesetResource = GetVmssResource(name); var patch = new VirtualMachineScaleSetPatch(); patch.Sku.Capacity = capacity; await scalesetResource.UpdateAsync(WaitUntil.Started, patch); return(OneFuzzResultVoid.Ok); } else { return(OneFuzzResultVoid.Error(canUpdate.ErrorV)); } }
public async Async.Task <OneFuzzResultVoid> UpdateExtensions(Guid name, IList <VirtualMachineScaleSetExtensionData> extensions) { var canUpdate = await CheckCanUpdate(name); if (canUpdate.IsOk) { _log.Info($"updating VM extensions: {name}"); var res = GetVmssResource(name); var patch = new VirtualMachineScaleSetPatch(); foreach (var ext in extensions) { patch.VirtualMachineProfile.ExtensionProfile.Extensions.Add(ext); } var _ = await res.UpdateAsync(WaitUntil.Started, patch); _log.Info($"VM extensions updated: {name}"); return(OneFuzzResultVoid.Ok); } else { return(OneFuzzResultVoid.Error(canUpdate.ErrorV)); } }