/// <summary> /// Given a publish settings files - adds a management certificate to the request /// </summary> IDeploymentActivity ICertificateActivity.AddPublishSettingsFromFile(string path) { var settings = new PublishSettingsExtractor(path); ManagementCertificate = settings.AddPublishSettingsToPersonalMachineStore(); return(this); }
/// <summary> /// Adds a .publishsettings file to get the certificate extract /// </summary> IStorageActivity ICertificateActivity.AddPublishSettings(string path) { var settings = new PublishSettingsExtractor(path); ManagementCertificate = settings.GetCertificateFromFile(); return(this); }
public void TestGetSubscriptionsInPublishsettings() { var settings = new PublishSettingsExtractor(_fullFileName); var dictionary = settings.GetSubscriptions(); dictionary.Count.Should().Be(5, "Number of subscriptions in Xml .publishsettings string"); }
/// <summary> /// Adds a .publishsettings file and extracts the certificate /// </summary> IVirtualMachineActivity ICertificateActivity.AddPublishSettingsFromFile(string path) { var settings = new PublishSettingsExtractor(path); Properties.Certificate = settings.GetCertificateFromFile(); return(this); }
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); }
/// <summary> /// Returns a watcher which will indicate when the status of the deployment and role by extension has changed /// </summary> /// <param name="serviceName">the name of the hosted service</param> /// <param name="roleName">the name of the role</param> /// <param name="slot">the name of the deployment slot either production or staging</param> /// <param name="certificateThumbprint">the thumbprint of the management certificate</param> /// <returns>A DeploymentStatusWatcher class instance</returns> public DeploymentStatusWatcher GetRoleStatusChangedWatcher(string serviceName, string roleName, DeploymentSlot slot, string certificateThumbprint) { X509Certificate2 certificate = PublishSettingsExtractor.FromStore(certificateThumbprint); return(new DeploymentStatusWatcher(serviceName, slot, certificate, _subscriptionId)); }
/// <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); }
public void TestVersion2Schema() { var settings = PublishSettingsExtractor.GetFromXml(V2); var dictionary = settings.GetSubscriptions(); dictionary.Count.Should().Be(1, "Number of subscriptions in Xml .publishsettings string"); settings.SchemaVersion.Should().Be(2, "the schema number used"); }
public void TestVersion2SchemaWithForeginCultureSettings() { Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE"); var settings = PublishSettingsExtractor.GetFromXml(V2); var dictionary = settings.GetSubscriptions(); dictionary.Count.Should().Be(1, "Number of subscriptions in Xml .publishsettings string"); settings.SchemaVersion.Should().Be(2, "the schema number used"); }
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); }
public void TestAddCertificateToStoreFromPublishSettings() { var cert = PublishSettingsExtractor.AddPublishSettingsToPersonalMachineStore(Publishsettings); cert.Should().NotBeNull("Contains a ASN1/DER encoded certificate"); cert.HasPrivateKey.Should().BeTrue("Contains a PKCS#12 structure"); var cert2 = PublishSettingsExtractor.FromStore(cert.Thumbprint); cert2.Thumbprint.Should().Be(cert.Thumbprint, "The same certificate"); cert2.HasPrivateKey.Should().BeTrue("Same certificate as above should exist and be imported with pvk into the personal store"); PublishSettingsExtractor.RemoveFromStore(cert2.Thumbprint); }
// 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(); } }
/// <summary> /// Adds a services certificate to the cloud service /// </summary> /// <param name="thumbprint">The thumbprint of the certificate to get from the store</param> /// <param name="password">The password used to export the key</param> public void UploadServiceCertificate(string thumbprint, string password) { X509Certificate2 certificate = null; try { certificate = PublishSettingsExtractor.FromStore(thumbprint, StoreLocation.LocalMachine); } catch (Exception) { certificate = certificate ?? PublishSettingsExtractor.FromStore(thumbprint); if (certificate == null) { throw new ApplicationException("unable to find certificate with thumbprint " + thumbprint + " in local store"); } } UploadServiceCertificate(certificate, password); }
/// <summary> /// Executes the query performing the underlying operation /// </summary> /// <typeparam name="T">The type used to define the query - CloudService or StorageAccount</typeparam> /// <param name="inputs">The Authentication inputs needed to fulfil the operation</param> /// <returns>An IQueryable interface</returns> public IQueryable <T> Execute <T>(LinqToAzureInputs inputs) { if (typeof(T) != GetValidType()) { throw new InvalidQueryException("Mismatch between generic types StorageAccount type expected"); } // Get the place name(s) to query the Web service with. var sf = new VirtualMachineFinder(_expression != null ? _expression.Body : null); string cloudServiceName = sf.CloudServiceName; if (String.IsNullOrEmpty(cloudServiceName)) { throw new InvalidQueryException("You must specify a single cloud service in your query"); } // Call the Web service and get the results. if (_roles == null) { // get the cert in the form of an x509v3 var certificate = PublishSettingsExtractor.FromStore(inputs.ManagementCertificateThumbprint); try { var properties = new WindowsVirtualMachineProperties() { CloudServiceName = cloudServiceName }; var command = new GetVirtualMachineContextCommand(properties) { SubscriptionId = inputs.SubscriptionId, Certificate = certificate }; command.Execute(); _roles = command.PersistentVm; } catch (Exception ex) { throw new ApplicationException("Unable to query Windows Azure", ex); } } //return _roles.AsQueryable(); return((IQueryable <T>)_roles.AsQueryable()); }
/// <summary> /// Searches various stores to find the certificate with the matching thumbprint id /// </summary> ISubscriptionQuery ICertificateActivity.AddCertificateFromStore(string thumbprint) { ManagementCertificate = PublishSettingsExtractor.FromStore(thumbprint); return(this); }
/// <summary> /// Added the deployment /// </summary> /// <param name="certificateThumbprint">The thumbprint of the certificate being used to update the deployment status</param> /// <param name="serviceName">The name of the cloud service</param> /// <param name="slot">The deployment slot</param> /// <returns>A RoleContextManager class instance</returns> public RoleContextManager GetRoleContextManager(string certificateThumbprint, string serviceName, DeploymentSlot slot) { X509Certificate2 certificate = PublishSettingsExtractor.FromStore(certificateThumbprint); return(new RoleContextManager(_subscriptionId, certificate, serviceName, slot)); }
private X509Certificate2 GetCertificateFromPublishSettings(string publishSettings) { var settings = new PublishSettingsExtractor(publishSettings); return(settings.AddPublishSettingsToPersonalMachineStore()); }
/// <summary> /// Given a certificate thumbprint scours several local stores to find the cert by thumbprint /// </summary> IDeploymentActivity ICertificateActivity.AddCertificateFromStore(string thumbprint) { ManagementCertificate = PublishSettingsExtractor.FromStore(thumbprint); return(this); }
/// <summary> /// Given a publish settings files - adds a management certificate to the request /// </summary> IDeploymentActivity ICertificateActivity.AddPublishSettingsFromFile(string path) { var settings = new PublishSettingsExtractor(path); ManagementCertificate = settings.AddPublishSettingsToPersonalMachineStore(); return this; }
/// <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; }
/// <summary> /// Given a publish settings block of Xml - adds a management certificate to the request /// </summary> IDeploymentActivity ICertificateActivity.AddPublishSettingsFromXml(string xml) { ManagementCertificate = PublishSettingsExtractor.GetCertificateFromXml(xml); return(this); }
ISqlAzureSecurity ISqlCertificateActivity.AddCertificateFromStore(string thumbprint) { ManagementCertificate = PublishSettingsExtractor.FromStore(thumbprint); return(this); }
/// <summary> /// Adds a .publishsettings profile from a given body of Xml /// </summary> IVirtualMachineActivity ICertificateActivity.AddPublishSettingsFromXml(string xml) { Properties.Certificate = PublishSettingsExtractor.AddPublishSettingsToPersonalMachineStore(xml); return(this); }
/// <summary> /// Adds a .publishsettings file to get the certificate extract /// </summary> IStorageActivity ICertificateActivity.AddPublishSettings(string path) { var settings = new PublishSettingsExtractor(path); ManagementCertificate = settings.GetCertificateFromFile(); return this; }
/// <summary> /// Adds a .publishsettings profile from a given body of Xml /// </summary> public ISubscriptionQuery AddPublishSettingsFromXml(string xml) { ManagementCertificate = PublishSettingsExtractor.GetCertificateFromXml(xml); return(this); }
/// <summary> /// Gets an existing certificate given a thumbprint from the Local Stores /// </summary> public X509Certificate2 GetExisting(string thumbprint, string password) { PvkPassword = password; return(Certificate = PublishSettingsExtractor.FromStore(thumbprint)); }
public void PostProcess() { var extractor = new PublishSettingsExtractor(PublishSettings); var client = new StorageClient(SubscriptionId, extractor.AddPublishSettingsToPersonalMachineStore()); var keys = client.GetStorageAccountKeys(StorageName); ConnectionString = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageName, keys[0]); // put a container create process here - add this method to fluent!!! var blobClient = new BlobClient(SubscriptionId, "packages", StorageName, keys[0]); blobClient.CreatBlobContainer(); }
/// <summary> /// Adds a .publishsettings file and extracts the certificate /// </summary> IVirtualMachineActivity ICertificateActivity.AddPublishSettingsFromFile(string path) { var settings = new PublishSettingsExtractor(path); Properties.Certificate = settings.GetCertificateFromFile(); return this; }
/// <summary> /// Adds a certificate from the store /// </summary> IVirtualMachineActivity ICertificateActivity.AddCertificateFromStore(string thumbprint) { Properties.Certificate = PublishSettingsExtractor.FromStore(thumbprint); return(this); }