예제 #1
0
        /// <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));
            }
        }
 protected GlobalSettingsManager(string azurePath, string subscriptionsDataFile)
 {
     GlobalPaths        = new GlobalPathInfo(azurePath, subscriptionsDataFile);
     DefaultEnvironment = WindowsAzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud];
     environments       = new Dictionary <string, WindowsAzureEnvironment>(
         WindowsAzureEnvironment.PublicEnvironments,
         StringComparer.InvariantCultureIgnoreCase);
 }
예제 #3
0
        public string GetManagementPortalUrl(string environment = null, string realm = null)
        {
            // If no environment provided assume using the current environment.
            environment = string.IsNullOrEmpty(environment) ? DefaultEnvironment.Name : environment;
            WindowsAzureEnvironment environmentObject = GetEnvironment(environment);

            Debug.Assert(!string.IsNullOrEmpty(environmentObject.PublishSettingsFileUrl));

            StringBuilder managementPortalUrl = new StringBuilder(environmentObject.ManagementPortalUrl);

            if (!string.IsNullOrEmpty(realm))
            {
                managementPortalUrl.AppendFormat(Resources.PublishSettingsFileRealmFormat, realm);
            }

            return(managementPortalUrl.ToString());
        }
예제 #4
0
        /// <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));
            }
        }
예제 #5
0
 protected GlobalSettingsManager(string azurePath, string subscriptionsDataFile)
 {
     GlobalPaths        = new GlobalPathInfo(azurePath, subscriptionsDataFile);
     DefaultEnvironment = WindowsAzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud];
 }
        /// <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));
            }
        }