{"record":{"id":"e08e15e0e24324dc","repo":"abpframework/abp","slug":"saving-blob-args-blobname-does-already-exists-e08e15","errorCode":null,"errorMessage":"Saving BLOB '{args.BlobName}' does already exists in the container '{GetContainerName(args)}'! Set OverrideExisting if it should be overwritten.","messagePattern":"Saving BLOB '(.+?)' does already exists in the container '(.+?)'! Set OverrideExisting if it should be overwritten\\.","errorType":"exception","errorClass":"BlobAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProvider.cs","lineNumber":29,"sourceCode":"    protected IAzureBlobNameCalculator AzureBlobNameCalculator { get; }\n    protected IBlobNormalizeNamingService BlobNormalizeNamingService { get; }\n\n    public AzureBlobProvider(\n        IAzureBlobNameCalculator azureBlobNameCalculator,\n        IBlobNormalizeNamingService blobNormalizeNamingService)\n    {\n        AzureBlobNameCalculator = azureBlobNameCalculator;\n        BlobNormalizeNamingService = blobNormalizeNamingService;\n    }\n\n    public override async Task SaveAsync(BlobProviderSaveArgs args)\n    {\n        var blobName = AzureBlobNameCalculator.Calculate(args);\n        var configuration = args.Configuration.GetAzureConfiguration();\n\n        if (!args.OverrideExisting && await BlobExistsAsync(args, blobName))\n        {\n            throw new BlobAlreadyExistsException($\"Saving BLOB '{args.BlobName}' does already exists in the container '{GetContainerName(args)}'! Set {nameof(args.OverrideExisting)} if it should be overwritten.\");\n        }\n\n        if (configuration.CreateContainerIfNotExists)\n        {\n            await CreateContainerIfNotExists(args);\n        }\n\n        await GetBlobClient(args, blobName).UploadAsync(args.BlobStream, true);\n    }\n\n    public override async Task<bool> DeleteAsync(BlobProviderDeleteArgs args)\n    {\n        var blobName = AzureBlobNameCalculator.Calculate(args);\n\n        if (await BlobExistsAsync(args, blobName))\n        {\n            return await GetBlobClient(args, blobName).DeleteIfExistsAsync();\n        }","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProvider.cs#L11-L47","documentation":"Thrown by AzureBlobProvider.SaveAsync when OverrideExisting is false and AzureBlobNameCalculator-calculated blob name already exists in the container, as determined by BlobExistsAsync. It prevents silent overwrites of existing Azure blobs; the check runs before CreateContainerIfNotExists and the actual UploadAsync call.","triggerScenarios":"Saving a blob through the Azure provider where the target blob name already exists and OverrideExisting was not set to true. Note that even with this guard, the subsequent UploadAsync passes overwrite:true to the BlobClient, so this exception is the only overwrite barrier.","commonSituations":"Re-saving a stable-key blob (user avatar, generated report), retrying an upload that completed server-side, or concurrent writers racing for the same key.","solutions":["Pass overrideExisting: true when the new content should replace the existing blob.","Use a unique blob name per save to avoid collisions entirely.","Call ExistsAsync first and branch your logic.","Delete the stale blob before re-saving under the same key."],"exampleFix":"// before\nawait container.SaveAsync(\"report.pdf\", stream);\n\n// after\nawait container.SaveAsync(\"report.pdf\", stream, overrideExisting: true);","handlingStrategy":"validation","validationCode":"if (await container.ExistsAsync(blobName))\n{\n    await container.SaveAsync(blobName, stream, overrideExisting: true);\n    return;\n}\nawait container.SaveAsync(blobName, stream);","typeGuard":"bool willConflict = !args.OverrideExisting && await container.ExistsAsync(blobName);","tryCatchPattern":"try { await container.SaveAsync(blobName, stream); }\ncatch (BlobAlreadyExistsException)\n{ /* rename key or retry with overrideExisting: true */ }","preventionTips":["Set OverrideExisting on update operations.","Use unique blob names for immutable uploads.","Note AzureBlobProvider.UploadAsync always uses overwrite:true, so this exception is the sole guard."],"tags":["blob-storage","azure","save","conflict","abp"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}