public virtual IEnumerable<BatchAccountContext> ListAccounts(Hashtable tag, string resourceGroupName = default(string))
{
// no account name so we're doing some sort of list. If no resource group, then list all accounts under the
// subscription otherwise all accounts in the resource group.
var response = string.IsNullOrEmpty(resourceGroupName)
? BatchManagementClient.BatchAccount.List()
: BatchManagementClient.BatchAccount.ListByResourceGroup(resourceGroupName);
var batchAccountContexts =
ListAllAccounts(response).
Where(acct => Helpers.MatchesTag(acct, tag)).
Select(resource => BatchAccountContext.ConvertAccountResourceToNewAccountContext(resource));
return batchAccountContexts;
}