{"record":{"id":"047ab47ea28d1175","repo":"abpframework/abp","slug":"failed-to-create-storage-zone-containername-s","errorCode":null,"errorMessage":"Failed to create storage zone '{containerName}'. Status: {response.StatusCode}, Error: {errorContent}","messagePattern":"Failed to create storage zone '(.+?)'\\. Status: (.+?), Error: (.+?)","errorType":"exception","errorClass":"AbpException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/DefaultBunnyClientFactory.cs","lineNumber":121,"sourceCode":"            {\n                { \"Name\", containerName },\n                { \"Region\", region },\n                { \"ZoneTier\", 0 }\n            };\n\n            var content = new StringContent(\n                JsonSerializer.Serialize(payload),\n                Encoding.UTF8,\n                \"application/json\");\n\n            var response = await client.PostAsync(\n                \"https://api.bunny.net/storagezone\",\n                content);\n\n            if (!response.IsSuccessStatusCode)\n            {\n                var errorContent = await response.Content.ReadAsStringAsync();\n                throw new AbpException(\n                    $\"Failed to create storage zone '{containerName}'. \" +\n                    $\"Status: {response.StatusCode}, Error: {errorContent}\");\n            }\n\n            var responseContent = await response.Content.ReadAsStringAsync();\n            var createdZone = JsonSerializer.Deserialize<BunnyStorageZoneModel>(responseContent);\n\n            if (createdZone == null)\n            {\n                throw new AbpException($\"Failed to deserialize the created storage zone response for '{containerName}'\");\n            }\n\n            return createdZone;\n        }\n    }\n\n    protected virtual async Task<BunnyStorageZoneModel?> GetStorageZoneAsync(string accessKey, string containerName)\n    {","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/DefaultBunnyClientFactory.cs#L103-L139","documentation":"Thrown by DefaultBunnyClientFactory.CreateStorageZoneAsync when the POST to https://api.bunny.net/storagezone returns a non-success status code. The AbpException embeds the HTTP status code and the raw error body read from the response. This occurs during auto-creation (CreateContainerIfNotExists=true) when the Bunny API rejects the zone-creation request.","triggerScenarios":"CreateStorageZoneAsync posts a payload {Name, Region, ZoneTier:0}; if Bunny returns non-2xx (e.g. 401 unauthorized, 400 duplicate name, 402 billing limit), the exception is raised with the status and error content.","commonSituations":"Invalid or expired AccessKey (401), a storage zone with that name already exists (409/400), account billing limits reached, an unsupported region value, or transient Bunny API errors.","solutions":["Read the Status and Error in the message: 401 -> fix AccessKey; duplicate -> the zone already exists (remove CreateContainerIfNotExists or reuse it); billing -> resolve account limits.","Verify the AccessKey has storage-zone creation permissions.","Ensure the region is one Bunny accepts.","Retry transient 5xx failures with backoff."],"exampleFix":"// Diagnose from the embedded status/error, then:\n// - 401: correct AccessKey\n// - duplicate name: zone exists, set CreateContainerIfNotExists=false and use existing zone\n\"Bunny\": {\n  \"AccessKey\": \"<valid-account-key>\",\n  \"ContainerName\": \"my-zone\",\n  \"CreateContainerIfNotExists\": false\n}","handlingStrategy":"try-catch","validationCode":"// Verify the key can manage storage zones before enabling auto-create:\nif (configuration.AccessKey.IsNullOrWhiteSpace())\n    throw new InvalidOperationException(\"Bunny AccessKey required to create a zone.\");","typeGuard":"bool canCreateZone = configuration.CreateContainerIfNotExists && !configuration.AccessKey.IsNullOrWhiteSpace();","tryCatchPattern":"try { await container.SaveAsync(blobName, stream); }\ncatch (AbpException ex) when (ex.Message.Contains(\"Failed to create storage zone\"))\n{\n    // parse embedded Status/Error: 401->key, duplicate->reuse, billing->account\n}","preventionTips":["Use an account-level AccessKey with storage-zone creation rights.","Avoid duplicate zone names; reuse existing zones when present.","Parse the embedded HTTP status to drive the fix."],"tags":["bunny","storage-zone","api","network","creation","abp"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}