Used to get certificates from the store or from .publishsettings
示例#1
0
 static void Main(string[] args)
 {
     // should have 5 arguments though subscription_id_source, path_to_pub_settings_source,
     // destination_account_name, destination_account_key, vhd_blob_path
     // 1. test the copy of the image from source to destination account
     // ReSharper disable once InconsistentNaming
     string subscription_id_source = args[0];
     // ReSharper disable once InconsistentNaming
     var certificate_source = new PublishSettingsExtractor(args[1]).AddPublishSettingsToPersonalMachineStore();
     // ReSharper disable once InconsistentNaming
     string account_name_destination = args[2];
     // ReSharper disable once InconsistentNaming
     string account_key_destination = args[3];
     // ReSharper disable once InconsistentNaming
     string source_image_path = args[4];
     var properties = new ImageProperties()
     {
         OperatingSystem = PlatformType.Linux,
         Description = "Test from Azure Fluent Management",
         ShowInGui = false,
         IsPremium = true
     };
     var client = new ImageManagementClient(subscription_id_source, certificate_source);
     var imageList = client.ImageList;
     imageList.ForEach(image => Console.WriteLine(image.Label));
     Console.WriteLine("Image sparkius exists: {0}", client.Exists("sparkius1"));
     //client.CopyAndRegisterImageInNewSubscription(account_name_destination, account_key_destination, null,
     //    "elastaimage", "sparkius", source_image_path, properties);
 }
        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);
        }
        public void TestGetCertificateThumbprint()
        {
            var cert = PublishSettingsExtractor.AddPublishSettingsToPersonalMachineStore(Publishsettings);

            var settings = new PublishSettingsExtractor(_fullFileName);
            string thumbprint = settings.GetCertificateThumbprint();
            thumbprint.Should().NotBeNullOrEmpty("Contains a thumbprint from the given file");
            thumbprint.Should().Be(cert.Thumbprint, "The same as the parsed certificate value");

            PublishSettingsExtractor.RemoveFromStore(cert.Thumbprint);
        }
示例#4
0
        static void Main(string[] args)
        {
            var publishsettings = @"C:\Users\Richard\Desktop\Engagements\AllAccounts.publishsettings";
            var settings = new PublishSettingsExtractor(publishsettings);

            _certificate = settings.AddPublishSettingsToPersonalMachineStore();
            var executor = ParseTokens(args);
            executor.Execute();
            System.Console.WriteLine();
            System.Console.WriteLine("Press any key to exit");
            System.Console.Read();
        }
        public static void ReadConfig(TestContext context)
        {
            publishSettingsFile = ConfigurationManager.AppSettings["Publish Settings File"];
            Assert.IsNotNull(publishSettingsFile);

            subscriptionId = ConfigurationManager.AppSettings["Subscription ID"];
            Assert.IsNotNull(subscriptionId);

            settings = PublishSettingsExtractor.GetFromFile(publishSettingsFile);
            Assert.IsNotNull(settings);

            certificate = settings.AddPublishSettingsToPersonalMachineStore();
            Assert.IsNotNull(certificate);
        }
 public void TestGetSubscriptionsInPublishsettings()
 {
     var settings = new PublishSettingsExtractor(_fullFileName);
     var dictionary = settings.GetSubscriptions();
     dictionary.Count.Should().Be(5, "Number of subscriptions in Xml .publishsettings string");
 }
        // check to see whether there is a management certificate and use it in the service management call
        private void EnsureManagementCertificate()
        {
            // get the management certificate first of all
            if (ManagementCertificate == null)
            {
                if (String.IsNullOrEmpty(PublishSettingsFile) && String.IsNullOrEmpty(SubscriptionId))
                    throw new ApplicationException("Unable to find publishsettings files or subscription id is empty");

                var settings = new PublishSettingsExtractor(PublishSettingsFile);
                ManagementCertificate = settings.AddPublishSettingsToPersonalMachineStore();
            }
        }
        private X509Certificate2 GetCertificateFromPublishSettings(string publishSettings)
        {
            var settings = new PublishSettingsExtractor(publishSettings);

            return settings.AddPublishSettingsToPersonalMachineStore();
        }
 /// <summary>
 /// Adds a .publishsettings file and extracts the certificate
 /// </summary>
 public ISubscriptionQuery AddPublishSettingsFromFile(string path)
 {
     var settings = new PublishSettingsExtractor(path);
     ManagementCertificate = settings.GetCertificateFromFile();
     return this;
 }