internal void Save() { // Create new Azure directory if doesn't exist // Directory.CreateDirectory(GlobalPaths.AzureDirectory); // Save *.publishsettings // General.SerializeXmlFile(PublishSettings, GlobalPaths.PublishSettingsFile); // Save certificate in the store // if (Certificate != null) { General.AddCertificateToStore(Certificate); } // Save service configuration // File.WriteAllText(GlobalPaths.ServiceConfigurationFile, new JavaScriptSerializer().Serialize(ServiceConfiguration)); // Save subscriptions // SubscriptionManager.SaveSubscriptions(GlobalPaths.SubscriptionsDataFile); }
/// <summary> /// Adds new Windows Azure environment. /// </summary> /// <param name="name">The name</param> /// <param name="publishSettingsFileUrl">The publish settings url</param> /// <param name="serviceEndpoint">The RDFE endpoint</param> /// <param name="managementPortalUrl">The portal url</param> /// <param name="storageBlobEndpointFormat">Blob service endpoint</param> /// <param name="storageQueueEndpointFormat">Queue service endpoint</param> /// <param name="storageTableEndpointFormat">Table service endpoint</param> public WindowsAzureEnvironment AddEnvironment(string name, string publishSettingsFileUrl, string serviceEndpoint = null, string managementPortalUrl = null, string storageBlobEndpointFormat = null, string storageQueueEndpointFormat = null, string storageTableEndpointFormat = null) { if (!EnvironmentExists(name) && !IsPublicEnvironment(name)) { WindowsAzureEnvironment environment = new WindowsAzureEnvironment() { Name = name, PublishSettingsFileUrl = publishSettingsFileUrl, ManagementPortalUrl = managementPortalUrl, ServiceEndpoint = serviceEndpoint, StorageBlobEndpointFormat = storageBlobEndpointFormat, StorageQueueEndpointFormat = storageQueueEndpointFormat, StorageTableEndpointFormat = storageTableEndpointFormat }; customEnvironments.Add(environment); General.EnsureDirectoryExists(GlobalPaths.EnvironmentsFile); General.SerializeXmlFile(customEnvironments, GlobalPaths.EnvironmentsFile); return(environment); } else { throw new Exception(string.Format(Resources.EnvironmentExists, name)); } }
/// <summary> /// Removes a custom Windows Azure environment. /// </summary> /// <param name="name">The environment name</param> public void RemoveEnvironment(string name) { if (EnvironmentExists(name) && !IsPublicEnvironment(name)) { int count = customEnvironments.RemoveAll(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); Debug.Assert(count == 1); General.SerializeXmlFile(customEnvironments, GlobalPaths.EnvironmentsFile); } else if (IsPublicEnvironment(name)) { throw new InvalidOperationException(string.Format(Resources.ChangePublicEnvironmentMessage, name)); } else { throw new KeyNotFoundException(string.Format(Resources.EnvironmentNotFound, name)); } }
public void SaveSubscriptions(string subscriptionsDataFile) { if (subscriptionsDataFile == null) { throw new ArgumentNullException("subscriptionsDataFile"); } var subscriptionsXml = new Subscriptions { Subscription = Subscriptions.Values.Select(subscription => { var subscriptionsSubscription = new SubscriptionsSubscription { CurrentStorageAccount = subscription.CurrentStorageAccount, name = subscription.SubscriptionName, ServiceEndpoint = subscription.ServiceEndpoint, SQLAzureServiceEndpoint = subscription.SqlAzureServiceEndpoint, SubscriptionId = subscription.SubscriptionId }; if (subscription.Certificate != null) { // Make sure certificate is in store General.AddCertificateToStore(subscription.Certificate); // Save the thumbprint for the certificate subscriptionsSubscription.Thumbprint = subscription.Certificate.Thumbprint; } return(subscriptionsSubscription); } ).ToArray() }; var parentDirectory = Directory.GetParent(subscriptionsDataFile); if (!parentDirectory.Exists) { parentDirectory.Create(); } General.SerializeXmlFile(subscriptionsXml, subscriptionsDataFile); }
/// <summary> /// Changes an existing Windows Azure environment information. /// </summary> /// <param name="name">The name</param> /// <param name="publishSettingsFileUrl">The publish settings url</param> /// <param name="serviceEndpoint">The RDFE endpoint</param> /// <param name="managementPortalUrl">The portal url</param> /// <param name="storageBlobEndpointFormat">Blob service endpoint</param> /// <param name="storageQueueEndpointFormat">Queue service endpoint</param> /// <param name="storageTableEndpointFormat">Table service endpoint</param> public WindowsAzureEnvironment ChangeEnvironment(string name, string publishSettingsFileUrl, string serviceEndpoint = null, string managementPortalUrl = null, string storageBlobEndpointFormat = null, string storageQueueEndpointFormat = null, string storageTableEndpointFormat = null) { if (EnvironmentExists(name) && !IsPublicEnvironment(name)) { WindowsAzureEnvironment environment = GetEnvironment(name); environment.PublishSettingsFileUrl = General.GetNonEmptyValue( environment.PublishSettingsFileUrl, publishSettingsFileUrl); environment.ManagementPortalUrl = General.GetNonEmptyValue( environment.ManagementPortalUrl, managementPortalUrl); environment.ServiceEndpoint = General.GetNonEmptyValue(environment.ServiceEndpoint, serviceEndpoint); environment.StorageBlobEndpointFormat = General.GetNonEmptyValue( environment.StorageBlobEndpointFormat, storageBlobEndpointFormat); environment.StorageQueueEndpointFormat = General.GetNonEmptyValue( environment.StorageQueueEndpointFormat, storageQueueEndpointFormat); environment.StorageTableEndpointFormat = General.GetNonEmptyValue( environment.StorageTableEndpointFormat, storageTableEndpointFormat); General.SerializeXmlFile(customEnvironments, GlobalPaths.EnvironmentsFile); return(environment); } else if (IsPublicEnvironment(name)) { throw new InvalidOperationException(string.Format(Resources.ChangePublicEnvironmentMessage, name)); } else { throw new KeyNotFoundException(string.Format(Resources.EnvironmentNotFound, name)); } }