private static AzureSubscription PublishSubscriptionToAzureSubscription( ProfileClient azureProfileClient, PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s, string environment) { var certificate = GetCertificate(profile, s); if (string.IsNullOrEmpty(environment)) { var azureEnvironment = azureProfileClient.GetEnvironment(environment, s.ServiceManagementUrl ?? profile.Url, null); if (azureEnvironment != null) { environment = azureEnvironment.Name; } else { environment = EnvironmentName.AzureCloud; } } return(new AzureSubscription { Id = new Guid(s.Id), Name = s.Name, Environment = environment, Account = certificate.Thumbprint }); }
/// <summary> /// Get the test environment from a publish settings file /// </summary> /// <param name="filePath">The full path to the publish settings file</param> /// <returns>A Test environment with credentials and BaseUri set from the given PublishSettings file.</returns> public static TestEnvironment GetTestEnvironmentFromPublishSettingsFile(string filePath) { PublishData data = XmlUtilities.DeserializeXmlFile <PublishData>(filePath); string encodedCert = data.Items.First().ManagementCertificate; if (string.IsNullOrEmpty(encodedCert)) { encodedCert = data.Items.First().Subscription.First().ManagementCertificate; } if (!string.IsNullOrEmpty(encodedCert)) { X509Certificate2 managementCert = GetCertificateFromBase64String(encodedCert); data.Items.First().ManagementCertificate = managementCert.Thumbprint; PublishDataPublishProfileSubscription subscription = data.Items.First().Subscription.First(); subscription.ServiceManagementUrl = subscription.ServiceManagementUrl ?? data.Items[0].Url; return(new TestEnvironment { BaseUri = new Uri(subscription.ServiceManagementUrl), Credentials = new CertificateCloudCredentials(subscription.Id, managementCert) }); } throw new ArgumentException(string.Format("{0} is not a valid publish settings file, you must provide a valid publish settings " + "file in the environment variable {1}", filePath, TestPublishSettingsFileKey)); }
private static Uri GetManagementUri(PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { if (!string.IsNullOrEmpty(s.ServiceManagementUrl)) { return(new Uri(s.ServiceManagementUrl)); } else if (!string.IsNullOrEmpty(profile.Url)) { return(new Uri(profile.Url)); } return(null); }
private static Uri GetManagementUri(PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { if (!string.IsNullOrEmpty(s.ServiceManagementUrl)) { return new Uri(s.ServiceManagementUrl); } else if (!string.IsNullOrEmpty(profile.Url)) { return new Uri(profile.Url); } return null; }
private static WindowsAzureSubscription PublishSubscriptionToAzureSubscription( PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { return(new WindowsAzureSubscription { Certificate = GetCertificate(profile, s), SubscriptionName = s.Name, ServiceEndpoint = GetManagementUri(profile, s), SubscriptionId = s.Id }); }
private static WindowsAzureSubscription PublishSubscriptionToAzureSubscription( PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { return new WindowsAzureSubscription { Certificate = GetCertificate(profile, s), SubscriptionName = s.Name, ServiceEndpoint = GetManagementUri(profile, s), SubscriptionId = s.Id }; }
private static X509Certificate2 GetCertificate(PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { string certificateString; if (!string.IsNullOrEmpty(s.ManagementCertificate)) { certificateString = s.ManagementCertificate; } else { certificateString = profile.ManagementCertificate; } return WindowsAzureCertificate.FromPublishSettingsString(certificateString); }
private static WindowsAzureSubscription PublishSubscriptionToAzureSubscription( PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { return(new WindowsAzureSubscription { Certificate = GetCertificate(profile, s), SubscriptionName = s.Name, ServiceEndpoint = GetManagementUri(profile, s), ResourceManagerEndpoint = null, SubscriptionId = s.Id, SqlDatabaseDnsSuffix = WindowsAzureEnvironmentConstants.AzureSqlDatabaseDnsSuffix, }); }
private static WindowsAzureSubscription PublishSubscriptionToAzureSubscription( PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { return new WindowsAzureSubscription { Certificate = GetCertificate(profile, s), SubscriptionName = s.Name, ServiceEndpoint = GetManagementUri(profile, s), ResourceManagerEndpoint = null, SubscriptionId = s.Id, SqlDatabaseDnsSuffix = WindowsAzureEnvironmentConstants.AzureSqlDatabaseDnsSuffix, }; }
private static X509Certificate2 GetCertificate(PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { string certificateString; if (!string.IsNullOrEmpty(s.ManagementCertificate)) { certificateString = s.ManagementCertificate; } else { certificateString = profile.ManagementCertificate; } return(WindowsAzureCertificate.FromPublishSettingsString(certificateString)); }
private static X509Certificate2 GetCertificate(PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s) { string certificateString; if (!string.IsNullOrEmpty(s.ManagementCertificate)) { certificateString = s.ManagementCertificate; } else { certificateString = profile.ManagementCertificate; } X509Certificate2 certificate = new X509Certificate2(Convert.FromBase64String(certificateString), string.Empty); AzureSession.DataStore.AddCertificate(certificate); return(certificate); }