microsoft/ailab · error · ApplicationException
container does not exist
Error message
container {container} does not exist What it means
GetFile downloads a blob from an Azure Blob container and first verifies the container exists, throwing ApplicationException('container {container} does not exist') when the check fails. It then verifies the individual blob exists. This is the low-level file fetch used by GetPredictionAsync and other callers, so it surfaces whenever results are requested from a missing container.
Solutions
- Confirm the container exists in the target storage account and that the connection string points to the same account
- Re-run the analysis pipeline so results are saved before fetching files
- Validate/normalize the container id from the request before calling GetFile
- Check lifecycle management or cleanup jobs that might have removed the container
- Handle ApplicationException in callers to return a clear 'results expired or not found' response
Example fix
// before
var bytes = await service.GetFile(folderId, "original.png");
// after
var c = cloudBlobClient.GetContainerReference(folderId);
if (!await c.ExistsAsync()) throw new ApplicationException($"Prediction {folderId} expired; re-run the analysis");
var bytes = await service.GetFile(folderId, "original.png"); Defensive patterns
Strategy: try-catch
Validate before calling
var c = cloudBlobClient.GetContainerReference(container);
if (!await c.ExistsAsync())
throw new ApplicationException($"Container {container} does not exist"); Try / catch
try
{
var bytes = await service.GetFile(container, file);
}
catch (ApplicationException ex) when (ex.Message.StartsWith("container "))
{
logger.LogWarning(ex, "Missing blob container {Container}", container);
return NotFound($"Results for {container} are unavailable.");
} Prevention
- Validate container ids from user input (format, existence) before fetching
- Translate ApplicationException into meaningful HTTP responses
- Verify connection string parity between write and read services
- Check cleanup jobs and retention policies against expected result lifetime
When it happens
Trigger: Calling GetFile(container, file) with a container name that has no matching container in the storage account — stale/typo folder id, wrong storage account, or deleted container — or invoking it as part of GetPredictionAsync/data/content flows against a nonexistent folder.
Common situations: Expired or cleaned-up prediction containers; mismatched storage connection string between save and read paths; user-supplied container id containing invalid characters or typos; reading results before the writing run completed.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Container does not exist
- blobClient is null
- Invalid image dimensions
- A subscription key is required
- BotFrameworkOptions must be configured prior to setting up…
AI-assisted analysis of microsoft/ailab@89fe2fc620 (2026-09-13).
Data as JSON: /api/errors/826d2cecbaa7063a.
Report an issue: GitHub.
Appendix: source
Thrown at Sketch2Code/Sketch2Code.Core/Services/ObjectDetectionAppService.cs:292
detail.OriginalImage = await this.GetFile(folderId, "original.png");
detail.PredictionImage = await this.GetFile(folderId, "predicted.png");
detail.PredictedObjects = await this.GetFile<IList<PredictedObject>>(folderId, "results.json");
var groupBox = await this.GetFile<GroupBox>(folderId, "groups.json");
detail.GroupBox = new List<GroupBox> { groupBox };
return detail;
}
public async Task<IList<CloudBlobContainer>> GetPredictionsAsync()
{
return await Task.Run(() => _cloudBlobClient.ListContainers().Where(l => l.Name != "azure-webjobs-hosts")
.OrderByDescending(c => c.Properties.LastModified).ToList());
}
public async Task<byte[]> GetFile(string container, string file)
{
var blobcontainer = _cloudBlobClient.GetContainerReference(container);
if (!await blobcontainer.ExistsAsync())
{
throw new ApplicationException($"container {container} does not exist");
}
var blob = blobcontainer.GetBlobReference(file);
if (!await blob.ExistsAsync())
{
throw new ApplicationException($"file {file} does not exist in container {container}");
}
using (var ms = new MemoryStream())
{
await blob.DownloadToStreamAsync(ms);
return ms.ToArray();
}
}
public async Task<T> GetFile<T>(string container, string file)
{
var data = await this.GetFile(container, file);
if (data == null) return default(T);
return JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(data));
}View on GitHub (pinned to 89fe2fc620)