상속: IServiceClient
예제 #1
0
        public void Execute(DeploymentParameters deploymentParams)
        {
            var certificate = new PublishSettingsExtractor(deploymentParams.PublishSettingsFile)
                                  .AddPublishSettingsToPersonalMachineStore();

            var client = new ServiceClient(deploymentParams.SubscriptionId, certificate, deploymentParams.CloudServiceName);
            client.CreateNewCloudService(deploymentParams.DeploymentLocation);
        }
예제 #2
0
 public void Execute()
 {
     var linuxClient = new LinuxVirtualMachineClient(_applicationFactory.SubscriptionId,
         _applicationFactory.ManagementCertificate);
     var images = linuxClient.ListImages("Ubuntu Server 12.04 LTS");
     images.ForEach(image => System.Console.WriteLine(image.Label));
     var props = new List<LinuxVirtualMachineProperties>();
     for (int i = 1; i < 2; i++)
     {
         var properties = new LinuxVirtualMachineProperties()
         {
             CloudServiceName = "asos-yarn-spark4",
             HostName = "spark-node" + i,
             RoleName = "spark-node" + i,
             UserName = "******",
             AdministratorPassword = "******",
             DeploymentName = "spark-master",
             CustomTemplateName = images[0].Name,
             StorageAccountName = "mtlytics",
             PublicEndpoints = new List<InputEndpoint>()
             {
                 new InputEndpoint()
                 {
                     EndpointName = "SSL",
                     LocalPort = 22,
                     Port = 21 + i,
                     Protocol = Protocol.TCP
                 }
             },
             VmSize = VmSize.Small
         };
         //var linux1 = new LinuxVirtualMachineClient(_applicationFactory.SubscriptionId, _applicationFactory.ManagementCertificate)
         //{
         //    Properties = new List<LinuxVirtualMachineProperties>() { properties }
         //};
         //linux1.DeleteVirtualMachine(true, true, false, false);
         props.Add(properties);
     }
     var service = new ServiceClient(_applicationFactory.SubscriptionId,
         _applicationFactory.ManagementCertificate, "asos-yarn-spark4");
     var certificate = service.CreateServiceCertificateExportToFileSystem("elastacert", "AsosSp@rk20148yJed", "C:\\Projects\\cert_export");
     //var settings =
     //    new PublishSettingsExtractor(@"C:\Projects\ASOS Big Compute-12-30-2013-credentials.publishsettings");
     //var cert = settings.AddPublishSettingsToPersonalMachineStore();
     var linux = new LinuxVirtualMachineClient(_applicationFactory.SubscriptionId, _applicationFactory.ManagementCertificate);
     //linux.AddRolesToExistingDeployment(props, "asos-yarn-spark", null);
     linux.CreateNewVirtualMachineDeploymentFromTemplateGallery(props, "asos-yarn-spark4", new ServiceCertificateModel()
     {
         Password = "******",
         ServiceCertificate = certificate.DerEncodedCertificate
     });
 }
        private void AddServiceCertificateToRoles(ServiceCertificateModel serviceCertificate, string cloudServiceName, ref List<LinuxVirtualMachineProperties> properties)
        {
            // upload the service certificate if it exists for the ssh keys
            if (serviceCertificate != null)
            {
                var client = new ServiceClient(SubscriptionId, ManagementCertificate, cloudServiceName);
                client.UploadServiceCertificate(serviceCertificate.ServiceCertificate, serviceCertificate.Password, true);
                foreach (var linuxVirtualMachineProperty in properties)
                {
                    linuxVirtualMachineProperty.PublicKeys.Add(new SSHKey(KeyType.PublicKey)
                    {
                        FingerPrint = serviceCertificate.ServiceCertificate.GetCertHashString(),
                        Path = String.Format("/home/{0}/.ssh/authorized_keys", linuxVirtualMachineProperty.UserName)
                    });
                    linuxVirtualMachineProperty.KeyPairs.Add(new SSHKey(KeyType.KeyPair)
                    {
                        FingerPrint = serviceCertificate.ServiceCertificate.GetCertHashString(),
                        Path = String.Format("/home/{0}/.ssh/id_rsa", linuxVirtualMachineProperty.UserName)
                    });

                    linuxVirtualMachineProperty.DisableSSHPasswordAuthentication = true;
                }
            }
        }
 /// <summary>
 /// Used to construct the HostedServiceActivity
 /// </summary>
 /// <param name="manager">The DeploymentManager class</param>
 public HostedServiceActivity(DeploymentManager manager)
 {
     _manager = manager;
     _client = new ServiceClient(_manager.SubscriptionId, _manager.ManagementCertificate, _manager.HostedServiceName);
 }