Example #1
0
        //[Trait("Name", "TestVMScaleSetScenarioOperations_OrchestrationService")]
        public async Task TestVMScaleSetScenarioOperations_OrchestrationService()
        {
            EnsureClientsInitialized(LocationNorthEurope);

            ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true);

            // Create resource group
            var    rgName             = Recording.GenerateAssetName(TestPrefix);
            var    vmssName           = Recording.GenerateAssetName("vmss");
            string storageAccountName = Recording.GenerateAssetName(TestPrefix);
            VirtualMachineScaleSet inputVMScaleSet;
            var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);

            await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeleteAsync(rgName, "VMScaleSetDoesNotExist"));

            AutomaticRepairsPolicy automaticRepairsPolicy = new AutomaticRepairsPolicy()
            {
                Enabled = true
            };
            var getTwoVirtualMachineScaleSet = await CreateVMScaleSet_NoAsyncTracking(
                rgName,
                vmssName,
                storageAccountOutput,
                imageRef,
                null,
                (vmScaleSet) =>
            {
                vmScaleSet.Overprovision = false;
            },
                createWithManagedDisks : true,
                createWithPublicIpAddress : false,
                createWithHealthProbe : true,
                automaticRepairsPolicy : automaticRepairsPolicy);

            VirtualMachineScaleSet getResponse = getTwoVirtualMachineScaleSet.Response;

            inputVMScaleSet = getTwoVirtualMachineScaleSet.Input;
            ValidateVMScaleSet(inputVMScaleSet, getResponse, hasManagedDisks: true);
            var getInstanceViewResponse = (await VirtualMachineScaleSetsOperations.GetInstanceViewAsync(rgName, vmssName)).Value;

            Assert.True(getInstanceViewResponse.OrchestrationServices.Count == 1);
            Assert.AreEqual("Running", getInstanceViewResponse.OrchestrationServices[0].ServiceState.ToString());
            Assert.AreEqual("AutomaticRepairs", getInstanceViewResponse.OrchestrationServices[0].ServiceName.ToString());

            ////TODO
            OrchestrationServiceStateInput orchestrationServiceStateInput = new OrchestrationServiceStateInput(OrchestrationServiceNames.AutomaticRepairs, OrchestrationServiceStateAction.Suspend);

            //OrchestrationServiceStateAction orchestrationServiceStateAction = new OrchestrationServiceStateAction();
            await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartSetOrchestrationServiceStateAsync(rgName, vmssName, orchestrationServiceStateInput));

            getInstanceViewResponse = await VirtualMachineScaleSetsOperations.GetInstanceViewAsync(rgName, vmssName);

            Assert.AreEqual(OrchestrationServiceState.Suspended.ToString(), getInstanceViewResponse.OrchestrationServices[0].ServiceState.ToString());

            orchestrationServiceStateInput = new OrchestrationServiceStateInput(OrchestrationServiceNames.AutomaticRepairs, OrchestrationServiceStateAction.Resume);
            await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartSetOrchestrationServiceStateAsync(rgName, vmssName, orchestrationServiceStateInput));

            getInstanceViewResponse = await VirtualMachineScaleSetsOperations.GetInstanceViewAsync(rgName, vmssName);

            Assert.AreEqual(OrchestrationServiceState.Running.ToString(), getInstanceViewResponse.OrchestrationServices[0].ServiceState.ToString());

            await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeleteAsync(rgName, vmssName));
        }