Azure / Azure-Functions

1.12k stars 199 forks source link

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

Open MarGraz opened 1 year ago

MarGraz commented 1 year ago

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 commented 1 year ago

I found this conversation on stackoverflow that seems interesting.

vijaykumar911 commented 1 year ago

@MarGraz Thanks for information will check and inform to you

vijaykumar911 commented 1 year ago

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.

MarGraz commented 1 year ago

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

dmytro-gokun commented 7 months ago

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

yarmoliq commented 2 weeks ago

Still having the issue