public virtual void DeleteAccount(string resourceGroupName, string accountName)
{
if (string.IsNullOrEmpty(resourceGroupName))
{
// use resource mgr to see if account exists and then use resource group name to do the actual lookup
resourceGroupName = GetGroupForAccount(accountName);
}
try
{
BatchManagementClient.BatchAccount.Delete(resourceGroupName, accountName);
}
catch (Rest.Azure.CloudException ex)
{
// TODO: Cleanup after TFS: 5914832
// RP puts the operation status token under the account that's
// being deleted, so we get a 404 from our Get Operation Status call when the
// deletion completes. We want 404 to throw an error on the initial delete
// request, but for now we want to consider a 404 error on the operation status
// polling as a success.
if (!(ex.Request.Method == HttpMethod.Get &&
ex.Message.Contains("Long running operation failed with status 'NotFound'")))
{
throw;
}
}
}