/// <summary>
        /// Used to deploy the virtual machine
        /// </summary>
        void IVirtualMachineDeployment.Deploy()
        {
            var command = new CreateWindowsVirtualMachineDeploymentCommand(Properties)
            {
                SubscriptionId = Properties.SubscriptionId,
                Certificate    = Properties.Certificate
            };

            command.Execute();
        }
예제 #2
0
        /// <summary>
        /// Creates a new virtual machine from a gallery template
        /// </summary>
        /// <param name="properties">Can be any gallery template</param>
        public IVirtualMachineClient CreateNewVirtualMachineFromTemplateGallery(WindowsVirtualMachineProperties properties)
        {
            // for the time being we're going to adopt the default powershell cmdlet behaviour and always create a new cloud services
            EnsureVirtualMachineProperties(properties);
            if (!properties.UseExistingCloudService)
            {
                var cloudServiceCommand = new CreateCloudServiceCommand(properties.CloudServiceName, "Created by Fluent Management", properties.Location)
                {
                    SubscriptionId = properties.SubscriptionId,
                    Certificate    = properties.Certificate
                };
                cloudServiceCommand.Execute();
            }
            // continue to the create the virtual machine in the cloud service
            var command = new CreateWindowsVirtualMachineDeploymentCommand(properties)
            {
                SubscriptionId = properties.SubscriptionId,
                Certificate    = properties.Certificate
            };

            command.Execute();
            // start the role up -- this could take a while the previous two operations are fairly lightweight
            // and the provisioning doesn't occur until the role starts not when it is created
            var startCommand = new StartVirtualMachineCommand(properties)
            {
                SubscriptionId = properties.SubscriptionId,
                Certificate    = properties.Certificate
            };

            startCommand.Execute();
            // important here to force a refresh - just in case someone to conduct an operation on the VM in a single step
            Properties = properties;
            var vm = VirtualMachine;

            // create a new client and return this so that properties can be populated automatically
            return(new WindowsVirtualMachineClient(properties));
        }