Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Microsoft.Azure.WebJobs.Extensions.Storage version 5.1.2 and Azure Functions v. 4.2.0, error: "The specified container already exists", status 409

Open MarGraz opened this issue 2 years ago • 6 comments

I'm using .net 6 and Azure Function v. 4, and I get the error: "The specified container already exists", status 409.

Those are the dependencies in my project:

    <PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
    <PackageReference Include="Azure.Identity" Version="1.8.2" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.1.2" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />

The exception seems to be called by:

BlobContainerClient.CreateIfNotExists ---> BlobContainerClient.Create

it seems to happen in my implementation when I use:

await blobContainerClient.CreateIfNotExistsAsync(PublicAccessType.BlobContainer);

I see this error in Azure Application Insights:

Azure.RequestFailedException: The specified container already exists.
RequestId:7aadc04c-601e-0051-2726-7fab43000000
Time:2023-05-05T07:54:33.5483399Z
Status: 409 (The specified container already exists.)
ErrorCode: ContainerAlreadyExists

Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>ContainerAlreadyExists</Code><Message>The specified container already exists.
RequestId:7aadc04c-601e-0051-2726-7fab43000000
Time:2023-05-05T07:54:33.5483399Z</Message></Error>

Headers:
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 7aadc04c-601e-0051-2726-7fab43000000
x-ms-client-request-id: 45bb8263-7256-4297-9f81-12c74c6ecb1d
x-ms-version: 2022-11-02
x-ms-error-code: ContainerAlreadyExists
Date: Fri, 05 May 2023 07:54:32 GMT
Content-Length: 230
Content-Type: application/xml

   at Azure.Storage.Blobs.ContainerRestClient.Create(Nullable`1 timeout, IDictionary`2 metadata, Nullable`1 access, String defaultEncryptionScope, Nullable`1 preventEncryptionScopeOverride, CancellationToken cancellationToken)
   at Azure.Storage.Blobs.BlobContainerClient.CreateInternal(PublicAccessType publicAccessType, IDictionary`2 metadata, BlobContainerEncryptionScopeOptions encryptionScopeOptions, Boolean async, CancellationToken cancellationToken, String operationName)

Do you know if it is available a fix?

Thank you

Originally posted by @MarGraz in https://github.com/Azure/Azure-Functions/issues/2166#issuecomment-1536138042

MarGraz avatar May 05 '23 11:05 MarGraz

I found this conversation on stackoverflow that seems interesting.

MarGraz avatar May 05 '23 12:05 MarGraz

@MarGraz Thanks for information will check and inform to you

vijaykumar911 avatar May 09 '23 10:05 vijaykumar911

The container already exists, check if it is present in storage account with using Azure Storage Explorer check container exists. If the container exists, you can rename the comtainer with storage explorer and update the connection string used by the Azure Function. The connection string should include the name of the container, so changing the name of the container should result in a new connection string and update the connection string in the Azure Function's configuration.

vijaykumar911 avatar May 13 '23 13:05 vijaykumar911

@vijaykumar911 the problem happen if the container already exists. In this case the desired behaviour is: "do nothing", instead it returns 409 error.

MarGraz avatar May 15 '23 14:05 MarGraz

Still a problem... Is it that hard to fix?

dmytro-gokun avatar Apr 05 '24 06:04 dmytro-gokun

Still having the issue

yarmoliq avatar Oct 30 '24 16:10 yarmoliq