/// <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)); }
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); }
/// <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> /// Adds a certificate from the store /// </summary> IVirtualMachineActivity ICertificateActivity.AddCertificateFromStore(string thumbprint) { Properties.Certificate = PublishSettingsExtractor.FromStore(thumbprint); return(this); }
/// <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> /// 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)); }
ISqlAzureSecurity ISqlCertificateActivity.AddCertificateFromStore(string thumbprint) { ManagementCertificate = PublishSettingsExtractor.FromStore(thumbprint); 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)); }