NewAzureService() public method

public NewAzureService ( string serviceName, string location ) : Microsoft.WindowsAzure.Management.Model.ManagementOperationContext
serviceName string
location string
return Microsoft.WindowsAzure.Management.Model.ManagementOperationContext
Exemplo n.º 1
0
        public void AdvancedProvisioning()
        {
            ServiceManagementCmdletTestHelper vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();
            vmPowershellCmdlets.ImportAzurePublishSettingsFile();
            string imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "MSFT", "testvmimage" }, false);
            string locationName = vmPowershellCmdlets.GetAzureLocationName(new[] { Resource.Location }, false);

            string newAzureVM1Name = Utilities.GetUniqueShortName("PSTestVM");
            string newAzureVM2Name = Utilities.GetUniqueShortName("PSTestVM");

            string newAzureSvcName = Utilities.GetUniqueShortName("PSTestService");
            vmPowershellCmdlets.NewAzureService(newAzureSvcName, newAzureSvcName, locationName);

            AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, VMSizeInfo.ExtraSmall, imageName);
            AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, VMSizeInfo.ExtraSmall, imageName);
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, "p@ssw0rd");
            AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
            AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/");

            PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
            PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);

            PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
            PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

            PersistentVM[] VMs = { persistentVM1, persistentVM2 };
            vmPowershellCmdlets.NewAzureVM(newAzureSvcName, VMs);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, newAzureSvcName);
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, newAzureSvcName);
            /* RemoveAzureService doesn't work */
            //vmPowershellCmdlets.RemoveAzureService(newAzureSvcName);
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, newAzureSvcName));
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, newAzureSvcName));
        }
Exemplo n.º 2
0
        public void CaptureImagingExportingImportingVMConfig()
        {
            ServiceManagementCmdletTestHelper vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();
            vmPowershellCmdlets.ImportAzurePublishSettingsFile(); // Import-AzurePublishSettingsFile
            var defaultAzureSubscription = vmPowershellCmdlets.SetDefaultAzureSubscription(Resource.DefaultSubscriptionName); // Set-AzureSubscription
            Assert.AreEqual(Resource.DefaultSubscriptionName, defaultAzureSubscription.SubscriptionName);

            //
            string imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "MSFT", "testvmimage" }, false); // Get-AzureVMImage
            Console.WriteLine("Image Name: {0}", imageName);

            string locationName = vmPowershellCmdlets.GetAzureLocationName(new[] { Resource.Location }, false); // Get-AzureLocation
            Console.WriteLine("Location Name: {0}", locationName);

            // Create a unique VM name
            string newAzureVMName = Utilities.GetUniqueShortName("PSTestVM");
            Console.WriteLine("VM Name: {0}", newAzureVMName);

            // Create a unique Service Name
            string newAzureSvcName = Utilities.GetUniqueShortName("PSTestService");
            vmPowershellCmdlets.NewAzureService(newAzureSvcName, newAzureSvcName, locationName);
            Console.WriteLine("VM Service Name: {0}", newAzureSvcName);

            // starting the test.

            AzureVMConfigInfo azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, VMSizeInfo.Small, imageName); // parameters for New-AzureVMConfig (-Name -InstanceSize -ImageName)
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, "p@ssw0rd"); // parameters for Add-AzureProvisioningConfig (-Windows -Password)
            PersistentVMConfigInfo persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
            PersistentVM persistentVM = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo); // New-AzureVMConfig & Add-AzureProvisioningConfig

            PersistentVM[] VMs = { persistentVM };
            vmPowershellCmdlets.NewAzureVM(newAzureSvcName, VMs); // New-AzureVM
            Console.WriteLine("The VM is successfully created: {0}", persistentVM.RoleName);
            PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, newAzureSvcName);
            Assert.AreEqual(vmRoleCtxt.Name, persistentVM.RoleName, true);

            vmPowershellCmdlets.StopAzureVM(newAzureVMName, newAzureSvcName); // Stop-AzureVM
            for (int i = 0; i < 3; i++)
            {
                vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, newAzureSvcName);
                if (vmRoleCtxt.InstanceStatus == "StoppedVM")
                    break;
                else
                {
                    Console.WriteLine("The status of the VM {0} : {1}", persistentVM.RoleName, vmRoleCtxt.InstanceStatus);
                    Thread.Sleep(120000);
                }
            }
            Assert.AreEqual(vmRoleCtxt.InstanceStatus, "StoppedVM", true);

            //TODO
            // RDP

            //TODO:
            // Run sysprep and shutdown

            // Check the status of VM
            //PersistentVMRoleContext vmRoleCtxt2 = vmPowershellCmdlets.GetAzureVM(newAzureVMName, newAzureSvcName); // Get-AzureVM -Name
            //Assert.AreEqual(newAzureVMName, vmRoleCtxt2.Name, true);  //

            // Save-AzureVMImage
            //string newImageName = "newImage";
            //string newImageLabel = "newImageLabel";
            //string postAction = "Delete";

            // Save-AzureVMImage -ServiceName -Name -NewImageName -NewImageLabel -PostCaptureAction
            //vmPowershellCmdlets.SaveAzureVMImage(newAzureSvcName, newAzureVMName, newImageName, newImageLabel, postAction);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(persistentVM.RoleName, newAzureSvcName);
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, newAzureSvcName));
        }