public static GetTestSettings ( string testSettings ) : void | ||
testSettings | string | |
리턴 | void |
public static void SetTestSettings() { vmPowershellCmdlets = new ServiceManagementCmdletTestHelper(); CredentialHelper.GetTestSettings(Resource.TestSettings); vmPowershellCmdlets.RemoveAzureSubscriptions(); vmPowershellCmdlets.ImportAzurePublishSettingsFile(CredentialHelper.PublishSettingsFile); if (string.IsNullOrEmpty(CredentialHelper.DefaultSubscriptionName)) { defaultAzureSubscription = vmPowershellCmdlets.GetCurrentAzureSubscription(); if (string.IsNullOrEmpty(Resource.DefaultSubscriptionName)) { CredentialHelper.DefaultSubscriptionName = defaultAzureSubscription.SubscriptionName; } } else { defaultAzureSubscription = vmPowershellCmdlets.SetDefaultAzureSubscription(CredentialHelper.DefaultSubscriptionName); } locationName = vmPowershellCmdlets.GetAzureLocationName(new[] { CredentialHelper.Location }); // Get-AzureLocation if (String.IsNullOrEmpty(locationName)) { Console.WriteLine("No location is selected!"); } Console.WriteLine("Location Name: {0}", locationName); if (defaultAzureSubscription.CurrentStorageAccountName == null && !string.IsNullOrEmpty(CredentialHelper.DefaultStorageName)) { SetDefaultStorage(); } try { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); // Get-AzureVMImage } catch { Console.WriteLine("Error occurred during Get-AzureVMImageName... imageName is not set."); } if (String.IsNullOrEmpty(imageName)) { Console.WriteLine("No image is selected!"); } else { Console.WriteLine("Image Name: {0}", imageName); } }
public static void SetTestSettings() { // Please remove this line once all tests are done System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return(true); // **** Always accept }; vmPowershellCmdlets = new ServiceManagementCmdletTestHelper(); CredentialHelper.GetTestSettings(Resource.TestSettings); vmPowershellCmdlets.RemoveAzureSubscriptions(); if (vmPowershellCmdlets.GetAzureEnvironment("ussouth").Count > 0) { Console.WriteLine("Removing ussouth environment..."); vmPowershellCmdlets.RunPSScript("Remove-AzureEnvironment -Name ussouth -Force"); } List <AzureEnvironment> environments = vmPowershellCmdlets.GetAzureEnvironment(); var serviceManagementUrl = GetServiceManagementUrl(CredentialHelper.PublishSettingsFile); foreach (var env in environments) { var envServiceManagementUrl = (string)env.Endpoints[AzureEnvironment.Endpoint.ServiceManagement]; if (!string.IsNullOrEmpty(envServiceManagementUrl)) { if (envServiceManagementUrl.Equals(serviceManagementUrl)) { currentEnvName = env.Name; var curEnv = vmPowershellCmdlets.GetAzureEnvironment(currentEnvName)[0]; Console.WriteLine("Using the existing environment: {0}", currentEnvName); Console.WriteLine("PublichSettingsFileUrl: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.PublishSettingsFileUrl)); Console.WriteLine("ServiceManagement: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ServiceManagement)); Console.WriteLine("ManagementPortalUrl: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ManagementPortalUrl)); Console.WriteLine("ActiveDirectory: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory)); Console.WriteLine("ActiveDirectoryServiceEndpointResourceId: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId)); Console.WriteLine("ResourceManager: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager)); Console.WriteLine("Gallery: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.Gallery)); Console.WriteLine("Graph: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.Graph)); break; } } } if (string.IsNullOrEmpty(currentEnvName)) { Console.WriteLine("Creating new environment... : {0}", TempEnvName); var prodEnv = vmPowershellCmdlets.GetAzureEnvironment("AzureCloud")[0]; vmPowershellCmdlets.RunPSScript(string.Format( @"Add-AzureEnvironment -Name {0} ` -PublishSettingsFileUrl {1} ` -ServiceEndpoint {2} ` -ManagementPortalUrl {3} ` -ActiveDirectoryEndpoint {4} ` -ActiveDirectoryServiceEndpointResourceId {5} ` -ResourceManagerEndpoint {6} ` -GalleryEndpoint {7} ` -GraphEndpoint {8}", TempEnvName, prodEnv.GetEndpoint(AzureEnvironment.Endpoint.PublishSettingsFileUrl), serviceManagementUrl, prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ManagementPortalUrl), prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory), prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId), prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager), prodEnv.GetEndpoint(AzureEnvironment.Endpoint.Gallery), prodEnv.GetEndpoint(AzureEnvironment.Endpoint.Graph))); vmPowershellCmdlets.ImportAzurePublishSettingsFile(CredentialHelper.PublishSettingsFile, TempEnvName); } else { Console.WriteLine("Using existing environment... : {0}", currentEnvName); vmPowershellCmdlets.ImportAzurePublishSettingsFile(CredentialHelper.PublishSettingsFile, currentEnvName); } var firstSub = vmPowershellCmdlets.GetAzureSubscription().First(); vmPowershellCmdlets.SelectAzureSubscription(firstSub.SubscriptionName); if (string.IsNullOrEmpty(CredentialHelper.DefaultSubscriptionName)) { defaultAzureSubscription = vmPowershellCmdlets.GetCurrentAzureSubscription(); if (string.IsNullOrEmpty(Resource.DefaultSubscriptionName)) { CredentialHelper.DefaultSubscriptionName = defaultAzureSubscription.SubscriptionName; } } else { defaultAzureSubscription = vmPowershellCmdlets.SetDefaultAzureSubscription(CredentialHelper.DefaultSubscriptionName); } locationName = vmPowershellCmdlets.GetAzureLocationName(new[] { CredentialHelper.Location }); // Get-AzureLocation if (String.IsNullOrEmpty(locationName)) { Console.WriteLine("No location is selected!"); } Console.WriteLine("Location Name: {0}", locationName); if (defaultAzureSubscription.CurrentStorageAccountName == null && !string.IsNullOrEmpty(CredentialHelper.DefaultStorageName)) { SetDefaultStorage(); } try { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); // Get-AzureVMImage } catch { Console.WriteLine("Error occurred during Get-AzureVMImageName... imageName is not set."); } if (String.IsNullOrEmpty(imageName)) { Console.WriteLine("No image is selected!"); } else { Console.WriteLine("Image Name: {0}", imageName); } }