Creates a deployment for a virtual machine and allows some preconfigured defaults from the image gallery
Inheritance: Elastacloud.AzureManagement.Fluent.Commands.Services.ServiceCommand
コード例 #1
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();
     // create a new client and return this so that properties can be populated automatically
     return new VirtualMachineClient(properties);
 }
コード例 #2
0
 /// <summary>
 /// Used to deploy the virtual machine 
 /// </summary>
 void IVirtualMachineDeployment.Deploy()
 {
     var command = new CreateWindowsVirtualMachineDeploymentCommand(Properties)
                       {
                           SubscriptionId = Properties.SubscriptionId,
                           Certificate = Properties.Certificate
                       };
     command.Execute();
 }