Microsoft.Azure.ServiceManagemenet.Common.ProfileClient.RemoveEnvironment C# (CSharp) Method

RemoveEnvironment() public method

public RemoveEnvironment ( string name ) : AzureEnvironment
name string
return Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment
        public AzureEnvironment RemoveEnvironment(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name", Resources.EnvironmentNameNeedsToBeSpecified);
            }
            if (AzureEnvironment.PublicEnvironments.ContainsKey(name))
            {
                throw new ArgumentException(Resources.RemovingDefaultEnvironmentsNotSupported, "name");
            }

            if (Profile.Environments.ContainsKey(name))
            {
                var environment = Profile.Environments[name];
                var subscriptions = Profile.Subscriptions.Values.Where(s => s.Environment == name).ToArray();
                foreach (var subscription in subscriptions)
                {
                    RemoveSubscription(subscription.Id);
                }
                Profile.Environments.Remove(name);
                return environment;
            }
            else
            {
                throw new ArgumentException(string.Format(Resources.EnvironmentNotFound, name), "name");
            }
        }