示例#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));
            }
        }