Inheritance: IVirtualMachineClient
示例#1
0
 public void Execute()
 {
     var properties = new WindowsVirtualMachineProperties()
                          {
                              AdministratorPassword = _applicationFactory.Password,
                              RoleName = _applicationFactory.RoleName,
                              Certificate = _applicationFactory.ManagementCertificate,
                              Location = LocationConstants.NorthEurope,
                              UseExistingCloudService = true,
                              SubscriptionId = _applicationFactory.SubscriptionId,
                              CloudServiceName = _applicationFactory.CloudServiceName,
                              PublicEndpoints = new List<InputEndpoint>(new[] {new InputEndpoint()
                              {
                                  EndpointName = "web",
                                  LocalPort = 80,
                                  Port = 80,
                                  Protocol = Protocol.TCP
                              }}),
                              VirtualMachineType = VirtualMachineTemplates.WindowsServer2008R2SP1,
                              VmSize = VmSize.Small,
                              StorageAccountName = "elastastorage",
                              DataDisks = new List<DataVirtualHardDisk>(){new DataVirtualHardDisk(){LogicalDiskSizeInGB = 100}}
                          };
     var client = new WindowsVirtualMachineClient(_applicationFactory.SubscriptionId, _applicationFactory.ManagementCertificate);
     var newClient = client.CreateNewVirtualMachineFromTemplateGallery(properties);
 }
示例#2
0
        public void Execute()
        {
            var properties = new WindowsVirtualMachineProperties()
            {
                AdministratorPassword = _applicationFactory.Password,
                RoleName = _applicationFactory.RoleName,
                Certificate = _applicationFactory.ManagementCertificate,
                SubscriptionId = _applicationFactory.SubscriptionId,
                CloudServiceName = _applicationFactory.CloudServiceName,
                DeploymentName = _applicationFactory.DeploymentName
            };
            var client = new WindowsVirtualMachineClient(properties);
            var vm = client.VirtualMachine;
            client.DeleteVirtualMachine(true, true);

            System.Console.WriteLine("Deleted virtual machine + disks");
        }
示例#3
0
        public void Execute()
        {
            var properties = new WindowsVirtualMachineProperties()
            {
                AdministratorPassword = _applicationFactory.Password,
                RoleName = _applicationFactory.RoleName,
                Certificate = _applicationFactory.ManagementCertificate,
                SubscriptionId = _applicationFactory.SubscriptionId,
                CloudServiceName = _applicationFactory.CloudServiceName,
                DeploymentName = _applicationFactory.DeploymentName
            };
            var client = new WindowsVirtualMachineClient(properties);
            var vm = client.VirtualMachine;

            System.Console.WriteLine("Virtual machine client");
            System.Console.WriteLine("======================");
            System.Console.WriteLine("Role name: {0}", vm.RoleName);
            System.Console.WriteLine("Role size: {0}", vm.RoleSize.ToString());

            string rdpFile = Path.Combine(_applicationFactory.PublishSettingsRoot, "vm.rdp");
            client.SaveRemoteDesktopFile(rdpFile);
            System.Console.WriteLine("RDP file saved to: {0}", rdpFile);
        }
        void IBuilder.TearDown()
        {
            var client = new WindowsVirtualMachineClient(_properties);
            string ipAddress = client.VirtualMachine.NetworkConfigurationSet.InputEndpoints[0].Vip;

            Console.WriteLine("The VIP is {0}", ipAddress);

            client.DeleteVirtualMachine();
            Console.WriteLine("Virtual machine has been deleted, with cloud service and storage");
        }
 void IBuilder.SpinUp()
 {
     var storageClient = new StorageClient(_subscriptionId, _certificate);
     storageClient.CreateNewStorageAccountIfNotExists(_storageAccountName, _storageLocationName);
     var client = new WindowsVirtualMachineClient(_subscriptionId, _certificate);
     var newClient = client.CreateNewVirtualMachineFromTemplateGallery(_properties);
     Console.WriteLine("Virtual machine now created - with diskname {0}", newClient.VirtualMachine.OSHardDisk.DiskName);
     Console.WriteLine("Getting and saving RD file");
     client.SaveRemoteDesktopFile(_rdpFile);
 }