/// <summary> /// Remove the given subscription from the given account /// </summary> /// <param name="account">The account to check</param> /// <param name="id">The id of the subscription to remove</param> public static void RemoveSubscription(this IAzureAccount account, Guid id) { if (account.HasSubscription(id)) { var remainingSubscriptions = account.GetSubscriptions().Where(s => new Guid(s) != id).ToArray(); if (remainingSubscriptions.Any()) { account.SetSubscriptions(remainingSubscriptions); } else { account.ExtendedProperties.Remove(AzureAccount.Property.Subscriptions); } } }
/// <summary> /// Set the subscriptiosn available to the given account /// </summary> /// <param name="account">The account to change</param> /// <param name="subscriptions">The subscriptions to replace the current subscription list in the account</param> public static void SetSubscriptions(this IAzureAccount account, List <IAzureSubscription> subscriptions) { account.SetSubscriptions(subscriptions.Select(s => s.Id.ToString()).ToArray()); }