public async Task TestVMScaleSetOperations_PowerOffWithSkipShutdown() { string rgName = Recording.GenerateAssetName(TestPrefix) + 1; string vmssName = Recording.GenerateAssetName("vmss"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachineScaleSet inputVMScaleSet; bool passed = false; EnsureClientsInitialized(LocationEastUs2UpperCase); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); StorageAccount storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); var getTwoVirtualMachineScaleSet = await CreateVMScaleSet_NoAsyncTracking(rgName, vmssName, storageAccountOutput, imageRef, createWithManagedDisks : true); VirtualMachineScaleSet vmScaleSet = getTwoVirtualMachineScaleSet.Item1; inputVMScaleSet = getTwoVirtualMachineScaleSet.Item2; await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartStartAsync(rgName, vmScaleSet.Name)); // Shutdown VM with SkipShutdown = true await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartPowerOffAsync(rgName, vmScaleSet.Name, true)); passed = true; Assert.True(passed); }
private async Task TestVMScaleSetOperationsInternal(bool hasManagedDisks = false) { ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); // Create resource group string rgName = Recording.GenerateAssetName(TestPrefix) + 1; var vmssName = Recording.GenerateAssetName("vmss"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachineScaleSet inputVMScaleSet; bool passed = false; var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); var getTwoVirtualMachineScaleSet = await CreateVMScaleSet_NoAsyncTracking( rgName, vmssName, storageAccountOutput, imageRef, createWithManagedDisks : hasManagedDisks); VirtualMachineScaleSet vmScaleSet = getTwoVirtualMachineScaleSet.Item1; inputVMScaleSet = getTwoVirtualMachineScaleSet.Item2; // TODO: AutoRest skips the following methods - Start, Restart, PowerOff, Deallocate await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartStartAsync(rgName, vmScaleSet.Name)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartReimageAsync(rgName, vmScaleSet.Name)); if (hasManagedDisks) { await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartReimageAllAsync(rgName, vmScaleSet.Name)); } await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartRestartAsync(rgName, vmScaleSet.Name)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartPowerOffAsync(rgName, vmScaleSet.Name)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeallocateAsync(rgName, vmScaleSet.Name)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeleteAsync(rgName, vmScaleSet.Name)); passed = true; Assert.True(passed); }
public async Task TestVMScaleSetBatchOperations() { EnsureClientsInitialized(DefaultLocation); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); // Create resource group string rgName = Recording.GenerateAssetName(TestPrefix) + 1; var vmssName = Recording.GenerateAssetName("vmss"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachineScaleSet inputVMScaleSet; bool passed = false; var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); var getTwoVirtualMachineScaleSet = await CreateVMScaleSet_NoAsyncTracking( rgName : rgName, vmssName : vmssName, storageAccount : storageAccountOutput, imageRef : imageRef, createWithManagedDisks : true, vmScaleSetCustomizer : (virtualMachineScaleSet) => virtualMachineScaleSet.UpgradePolicy = new UpgradePolicy { Mode = UpgradeMode.Manual } ); VirtualMachineScaleSet vmScaleSet = getTwoVirtualMachineScaleSet.Item1; inputVMScaleSet = getTwoVirtualMachineScaleSet.Item2; var virtualMachineScaleSetInstanceIDs = new VirtualMachineScaleSetVMInstanceIDs(new List <string>() { "0", "1" }); var virtualMachineScaleSetInstanceID = new List <string>() { "0", "1" }; var virtualMachineScaleSetRequ = new VirtualMachineScaleSetVMInstanceRequiredIDs(new List <string>() { "0", "1" }); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartStartAsync(rgName, vmScaleSet.Name, virtualMachineScaleSetInstanceIDs)); virtualMachineScaleSetInstanceIDs = new VirtualMachineScaleSetVMInstanceIDs(new List <string>() { "0" }); VirtualMachineScaleSetReimageParameters virtualMachineScaleSetReimageParameters = new VirtualMachineScaleSetReimageParameters { InstanceIds = virtualMachineScaleSetInstanceID }; await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartReimageAsync(rgName, vmScaleSet.Name, virtualMachineScaleSetReimageParameters)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartReimageAllAsync(rgName, vmScaleSet.Name, virtualMachineScaleSetInstanceIDs)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartPowerOffAsync(rgName, vmScaleSet.Name, null, virtualMachineScaleSetInstanceIDs)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartUpdateInstancesAsync(rgName, vmScaleSet.Name, virtualMachineScaleSetRequ)); virtualMachineScaleSetInstanceID = new List <string>() { "1" }; await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartRestartAsync(rgName, vmScaleSet.Name, virtualMachineScaleSetInstanceIDs)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeallocateAsync(rgName, vmScaleSet.Name, virtualMachineScaleSetInstanceIDs)); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeleteInstancesAsync(rgName, vmScaleSet.Name, virtualMachineScaleSetRequ)); passed = true; Assert.True(passed); }