public static void CreateAzureVirtualMachine(ComputeManagementClient computeClient, string serviceName, string deploymentName, string storageAccountName, string blobUrl)
        {
            VirtualMachineOSImageListResponse imagesList = computeClient.VirtualMachineOSImages.List();

            VirtualMachineOSImageListResponse.VirtualMachineOSImage imageToGet =
                imagesList.Images.FirstOrDefault(i => string.Equals(i.OperatingSystemType, "Windows", StringComparison.OrdinalIgnoreCase));

            VirtualMachineOSImageGetResponse gottenImage = computeClient.VirtualMachineOSImages.Get(imageToGet.Name);

            VirtualMachineCreateDeploymentParameters parameters = CreateVMParameters(gottenImage, deploymentName, storageAccountName, "SampleLabel", blobUrl);

            parameters.Roles[0].ConfigurationSets.Add(new ConfigurationSet
            {
                AdminUserName          = "******",
                AdminPassword          = "******",
                ConfigurationSetType   = ConfigurationSetTypes.WindowsProvisioningConfiguration,
                ComputerName           = serviceName,
                HostName               = string.Format("{0}.cloudapp.net", serviceName),
                EnableAutomaticUpdates = false,
                TimeZone               = "Pacific Standard Time"
            });

            OperationStatusResponse opResp =
                computeClient.VirtualMachines.CreateDeployment(serviceName, parameters);

            Assert.Equal(opResp.Status, OperationStatus.Succeeded);
        }
Beispiel #2
0
        public void CanAbortVirtualMachineDeployment()
        {
            TestUtilities.StartTest();
            using (fixture.ComputeClient = fixture.GetComputeManagementClient())
            {
                var serviceName = TestUtilities.GenerateName();

                var result = fixture.ComputeClient.HostedServices.Create(new HostedServiceCreateParameters
                {
                    Location    = fixture.Location,
                    Label       = serviceName,
                    ServiceName = serviceName
                });

                // assert that the call worked
                Assert.Equal(result.StatusCode, HttpStatusCode.Created);

                VirtualMachineOSImageListResponse imagesList = fixture.ComputeClient.VirtualMachineOSImages.List();

                VirtualMachineOSImageListResponse.VirtualMachineOSImage imageToGet =
                    imagesList.Images.FirstOrDefault(i => string.Equals(i.OperatingSystemType, "Windows", StringComparison.OrdinalIgnoreCase));

                VirtualMachineOSImageGetResponse gottenImage = fixture.ComputeClient.VirtualMachineOSImages.Get(imageToGet.Name);

                VirtualMachineCreateDeploymentParameters parameters = CreateVMParameters(gottenImage, serviceName);

                parameters.Roles[0].ConfigurationSets.Add(new ConfigurationSet
                {
                    AdminUserName          = "******",
                    AdminPassword          = ComputeTestsUtilities.GenerateRandomPassword(),
                    ConfigurationSetType   = ConfigurationSetTypes.WindowsProvisioningConfiguration,
                    ComputerName           = serviceName,
                    HostName               = string.Format("{0}.cloudapp.net", serviceName),
                    EnableAutomaticUpdates = false,
                    TimeZone               = "Pacific Standard Time"
                });

                OperationStatusResponse opResp =
                    fixture.ComputeClient.VirtualMachines.CreateDeployment(serviceName, parameters);

                Assert.Equal(opResp.Status, OperationStatus.Succeeded);

                var prepareParameters = new PrepareDeploymentMigrationParameters
                {
                    DestinationVirtualNetwork = "New",
                    ResourceGroupName         = string.Empty,
                    SubNetName         = string.Empty,
                    VirtualNetworkName = string.Empty
                };

                opResp = fixture.ComputeClient.Deployments.PrepareMigration(serviceName, parameters.Name, prepareParameters);
                Assert.Equal(opResp.Status, OperationStatus.Succeeded);

                opResp = fixture.ComputeClient.Deployments.AbortMigration(serviceName, parameters.Name);
                Assert.Equal(opResp.Status, OperationStatus.Succeeded);
            }

            TestUtilities.EndTest();
        }
Beispiel #3
0
        private VirtualMachineOSImageGetResponse FindVMImage(string imageType)
        {
            VirtualMachineOSImageListResponse imagesList = fixture.ComputeClient.VirtualMachineOSImages.List();

            VirtualMachineOSImageListResponse.VirtualMachineOSImage imageToGet =
                imagesList.Images.FirstOrDefault(i => i.ImageFamily == null ? false : i.ImageFamily.Contains(imageType));

            return(fixture.ComputeClient.VirtualMachineOSImages.Get(imageToGet.Name));
        }
Beispiel #4
0
        internal static void LogObject(this TestEasyLog log, VirtualMachineOSImageListResponse.VirtualMachineOSImage osImage)
        {
            if (osImage == null)
            {
                return;
            }

            log.Info(string.Format("OSImage Name: {0}", osImage.Name));
            log.Info(string.Format("OSImage Operating System: {0}", osImage.OperatingSystemType));
            if (!string.IsNullOrEmpty(osImage.RecommendedVMSize))
            {
                log.Info(string.Format("OSImage Recommended Size: {0}", osImage.RecommendedVMSize));
            }
        }
Beispiel #5
0
        public OSVirtualHardDisk GetOSVirtualHardDisk(string storageAccountName, string serviceName)
        {
            VirtualMachineOSImageListResponse imagesList = this.ComputeClient.VirtualMachineOSImages.List();

            VirtualMachineOSImageListResponse.VirtualMachineOSImage image =
                imagesList.Images.FirstOrDefault(i => string.Equals(i.OperatingSystemType, "Windows", StringComparison.OrdinalIgnoreCase));

            string blobDiskFormat = "http://{0}.blob.core.test-cint.azure-test.net/myvhds/{1}.vhd";

            Uri blobUrl = new Uri(string.Format(blobDiskFormat, storageAccountName, serviceName));

            return(new OSVirtualHardDisk()
            {
                HostCaching = VirtualHardDiskHostCaching.ReadWrite,
                MediaLink = blobUrl,
                SourceImageName = image.Name
            });
        }