In our environment we are constantly creating and deleting containers. Sometimes we also want to list through current containers using
azure.ContainerGroups.ListByResourceGroup
However if a resource is deleted, the enumerator can no longer iterate (e.g. even doing .ToList() will throw cloud exception). The work around is to use something like:
private static List<IContainerGroup> getContainerInstances(IAzure azure, string resouceGroup)
{
var brokenEnumerator = azure.ContainerGroups.ListByResourceGroup(resouceGroup).GetEnumerator();
var containerInstances = new List<IContainerGroup>();
while (true)
{
try
{
if (!brokenEnumerator.MoveNext())
{
break;
}
containerInstances.Add(brokenEnumerator.Current);
}
catch (CloudException)
{
// noop
}
}
return containerInstances;
}
imo the api should always be enumerable even if the resource was deleted
Hello
In our environment we are constantly creating and deleting containers. Sometimes we also want to list through current containers using
azure.ContainerGroups.ListByResourceGroup
However if a resource is deleted, the enumerator can no longer iterate (e.g. even doing .ToList() will throw cloud exception). The work around is to use something like:
imo the api should always be enumerable even if the resource was deleted