/// <summary>
 /// Restarts the virtual machine instance
 /// </summary>
 public void Restart()
 {
     // 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 restartCommand = new StartVirtualMachineCommand(Properties)
     {
         SubscriptionId = Properties.SubscriptionId,
         Certificate = Properties.Certificate
     };
     restartCommand.Execute();
 }
 /// <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();
     // create a new client and return this so that properties can be populated automatically
     return new VirtualMachineClient(properties);
 }
 /// <summary>
 /// Restarts the virtual machine instance
 /// </summary>
 public void Restart()
 {
     // 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
     Trace.WriteLine(String.Format("Restarting {0} virtual machines in deployment {1} in cloud service {2}",
        Properties.Count, Properties.First().DeploymentName, Properties.First().CloudServiceName));
     foreach (var linuxVirtualMachineProperty in Properties)
     {
         var restartCommand = new StartVirtualMachineCommand(linuxVirtualMachineProperty)
         {
             SubscriptionId = SubscriptionId,
             Certificate = ManagementCertificate
         };
         restartCommand.Execute();
         Trace.WriteLine(String.Format("VM restarted with hostname {0}", linuxVirtualMachineProperty.HostName));
     }
 }