/// <summary> /// Acts as main method of setting the azure publish profile by doing the following: /// 1. Extracts the certificate binary from *.azurePublish file /// 2. Create a X509Certificate2 certificate and adds it to store /// 3. Save the extracted certificate and *.azurePublis file to ..\ApplicationData\Azure SDK folder /// </summary> /// <returns>Message to display for to the user</returns> public string ImportAzurePublishSettingsProcess(string publishSettingsFilePath, string azureSdkPath) { GlobalComponents components = new GlobalComponents(publishSettingsFilePath, azureSdkPath); SafeWriteObject(string.Format(Resources.CertificateImportedMessage, components.Certificate.FriendlyName)); string msg = string.Format(Resources.PublishSettingsSetSuccessfully, GlobalPathInfo.GlobalSettingsDirectory); return msg; }
public static void AreEqualGlobalComponents(GlobalComponents globalComponents) { Assert.IsTrue(Directory.Exists(Data.AzureSdkAppDir)); Assert.IsTrue(File.Exists(globalComponents.GlobalPaths.GlobalSettings)); Assert.IsTrue(File.Exists(globalComponents.GlobalPaths.PublishSettings)); X509Store store = new X509Store(StoreName.My, System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); Assert.AreEqual<int>(1, store.Certificates.Find(X509FindType.FindByThumbprint, globalComponents.Certificate.Thumbprint, false).Count); }
public void RemoveAzureServiceProcess(string rootName, string inSubscription) { string serviceName; ServiceSettings settings = base.GetDefaultSettings(rootName, null, null, null, null, inSubscription, out serviceName); subscriptionId = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory).GetSubscriptionId(settings.Subscription); SafeWriteObjectWithTimestamp(Resources.RemoveServiceStartMessage, serviceName); SafeWriteObjectWithTimestamp(Resources.RemoveDeploymentMessage); StopAndRemove(rootName, serviceName, settings.Subscription, ArgumentConstants.Slots[Slot.Production]); StopAndRemove(rootName, serviceName, settings.Subscription, ArgumentConstants.Slots[Slot.Staging]); SafeWriteObjectWithTimestamp(Resources.RemoveServiceMessage); RemoveService(serviceName); }
public virtual string SetDeploymentStatusProcess(string rootPath, string newStatus, string slot, string subscription, string serviceName) { string result; subscriptionId = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory).GetSubscriptionId(subscription); result = CheckDeployment(newStatus, serviceName, slot); if (string.IsNullOrEmpty(result)) { SetDeployment(newStatus, serviceName, slot); new GetDeploymentStatus(this.Channel).WaitForState(newStatus, rootPath, serviceName, slot, subscription); } return result; }
internal string GetServiceSettingsPath(bool global) { string path; if (global) { path = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory).GlobalPaths.GlobalSettings; } else { path = new AzureService(base.GetServiceRootPath(), null).Paths.Settings; } return path; }
public void GlobalComponentsCreateNew() { foreach (string fileName in Data.ValidPublishSettings) { // Prepare GlobalComponents globalComponents = new GlobalComponents(fileName, Data.AzureSdkAppDir); PublishData actualPublishSettings = General.DeserializeXmlFile<PublishData>(Path.Combine(Data.AzureSdkAppDir, Resources.PublishSettingsFileName)); PublishData expectedPublishSettings = General.DeserializeXmlFile<PublishData>(fileName); // Assert AzureAssert.AreEqualGlobalComponents(actualPublishSettings.Items[0].ManagementCertificate, new GlobalPathInfo(Data.AzureSdkAppDir), new ServiceSettings(), expectedPublishSettings, globalComponents); // Clean new RemoveAzurePublishSettingsCommand().RemovePublishSettingsProcess(Data.AzureSdkAppDir); } }
public bool RemoveAzureServiceProcess(string rootName, string inSubscription) { string serviceName; ServiceSettings settings = base.GetDefaultSettings(rootName, null, null, null, null, inSubscription, out serviceName); subscriptionId = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory).GetSubscriptionId(settings.Subscription); if (!ShouldProcess("", string.Format(Resources.RemoveServiceWarning, serviceName), Resources.ShouldProcessCaption)) { return false; } SafeWriteObjectWithTimestamp(Resources.RemoveServiceStartMessage, serviceName); SafeWriteObjectWithTimestamp(Resources.RemoveDeploymentMessage); StopAndRemove(rootName, serviceName, settings.Subscription, ArgumentConstants.Slots[Slot.Production]); StopAndRemove(rootName, serviceName, settings.Subscription, ArgumentConstants.Slots[Slot.Staging]); SafeWriteObjectWithTimestamp(Resources.RemoveServiceMessage); RemoveService(serviceName); return true; }
public DeploymentSettings(ServiceSettings settings, string packagePath, string configPath, string label, string deploymentName) { Validate.ValidateNullArgument(settings, Resources.InvalidServiceSettingMessage); Validate.ValidateFileFull(packagePath, Resources.Package); Validate.ValidateFileFull(configPath, Resources.ServiceConfiguration); Validate.ValidateStringIsNullOrEmpty(label, "Label"); Validate.ValidateStringIsNullOrEmpty(deploymentName, "Deployment name"); this.ServiceSettings = settings; this.PackagePath = packagePath; this.ConfigPath = configPath; this.Label = label; this.DeploymentName = deploymentName; if (!string.IsNullOrEmpty(settings.Subscription)) { GlobalComponents globalComponents = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory); SubscriptionId = globalComponents.GetSubscriptionId(settings.Subscription); } else { throw new ArgumentNullException("settings.Subscription", Resources.InvalidSubscriptionNameMessage); } }
private ServiceSettings InitializeArguments(string rootPath, string inServiceName, string inSlot, string inSubscription, out string serviceName) { ServiceSettings settings = base.GetDefaultSettings(rootPath, inServiceName, inSlot, null, null, inSubscription, out serviceName); subscriptionId = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory).GetSubscriptionId(settings.Subscription); return settings; }
/// <summary> /// Initialize our model of the AzureService located at the given /// path along with its DeploymentSettings and SubscriptionId. /// </summary> /// <param name="rootPath">Root path of the Azure service.</param> internal void InitializeSettingsAndCreatePackage(string rootPath) { Debug.Assert(!string.IsNullOrEmpty(rootPath), "rootPath cannot be null or empty."); Debug.Assert(Directory.Exists(rootPath), "rootPath does not exist."); _azureService = new AzureService(rootPath, null); // If user provided a service name, change current service name to use it. // if (!string.IsNullOrEmpty(Name)) { _azureService.ChangeServiceName(Name, _azureService.Paths); } ServiceSettings defaultSettings = ServiceSettings.LoadDefault( _azureService.Paths.Settings, Slot, Location, Subscription, StorageAccountName, Name, _azureService.ServiceName, out _hostedServiceName); subscriptionId = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory) .GetSubscriptionId(defaultSettings.Subscription); SafeWriteObjectWithTimestamp(String.Format(Resources.PublishPreparingDeploymentMessage, _hostedServiceName, subscriptionId)); CreatePackage(); _deploymentSettings = new DeploymentSettings( defaultSettings, _azureService.Paths.CloudPackage, _azureService.Paths.CloudConfiguration, _hostedServiceName, string.Format(Resources.ServiceDeploymentName, defaultSettings.Slot)); }
private void InitializeArguments(string subscription) { string serviceName; string subscriptionName = base.GetDefaultSettings(null, null, null, null, null, subscription, out serviceName).Subscription; subscriptionId = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory).GetSubscriptionId(subscriptionName); }
public static void AreEqualGlobalComponents(string thumbprint, GlobalPathInfo paths, ServiceSettings globalSettings, PublishData publishSettings, GlobalComponents actual) { AreEqualGlobalPathInfo(paths, actual.GlobalPaths); AreEqualServiceSettings(globalSettings, actual.GlobalSettings); AreEqualPublishSettings(thumbprint, publishSettings, actual); }
public static void AreEqualGlobalComponents(GlobalComponents expected, GlobalComponents actual) { AreEqualGlobalComponents(expected.Certificate.Thumbprint, expected.GlobalPaths, expected.GlobalSettings, expected.PublishSettings, actual); }
private static void AreEqualPublishSettings(string thumbprint, PublishData publishSettings, GlobalComponents actual) { Assert.AreEqual<string>(publishSettings.Items[0].PublishMethod, actual.PublishSettings.Items[0].PublishMethod); Assert.AreEqual<string>(publishSettings.Items[0].Url, actual.PublishSettings.Items[0].Url); Assert.AreEqual<string>(thumbprint, actual.PublishSettings.Items[0].ManagementCertificate); Assert.AreEqual<int>(publishSettings.Items[0].Subscription.Length, actual.PublishSettings.Items[0].Subscription.Length); for (int i = 0; i < publishSettings.Items[0].Subscription.Length; i++) { Assert.AreEqual<string>(publishSettings.Items[0].Subscription[i].Id, actual.PublishSettings.Items[0].Subscription[i].Id); Assert.AreEqual<string>(publishSettings.Items[0].Subscription[i].Name, actual.PublishSettings.Items[0].Subscription[i].Name); } }
public static ServiceSettings LoadDefault(string path, string slot, string location, string subscription, string storageAccountName, string suppliedServiceName, string serviceDefinitionName, out string serviceName) { ServiceSettings local; ServiceSettings global = new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory).GlobalSettings; ServiceSettings defaultServiceSettings = new ServiceSettings(); // Load local settings if user provided local settings path // if (string.IsNullOrEmpty(path)) { local = new ServiceSettings(); } else { Validate.ValidateFileFull(path, Resources.ServiceSettings); local = Load(path); } defaultServiceSettings._slot = GetDefaultSlot(local.Slot, global.Slot, slot); defaultServiceSettings._location = GetDefaultLocation(local.Location, global.Location, location); defaultServiceSettings._subscription = GetDefaultSubscription(local.Subscription, global.Subscription, subscription); serviceName = GetServiceName(suppliedServiceName, serviceDefinitionName); defaultServiceSettings._storageAccountName = GetDefaultStorageName(local.StorageAccountName, global.StorageAccountName, storageAccountName, serviceName).ToLower(); return defaultServiceSettings; }