A community member has associated this post with a similar question:
How to ignore ETag checking and fix this error

Only moderators can edit this content.

Status: 412 : conditional header is not met error - How to ignore ETag checking

Sarah 156 Reputation points
I read blob content from Azure blob storage. The same Blob content is being changed by another program at the same time while it is being downloaded (i.e., new content is written and getting appended to the existing content). I get error in the below stream.Read() line. Which I believe is because of mismatch eTag values as file is both read and writen at the same time. How can I make it ignore checking for ETag.
I am actually not setting any "conditional headers" in the request. You could see the error details at the bottom (Status: 412 - The condition specified using HTTP conditional header(s) is not met),  I believe something is happening under the covers that I'm not aware of. 

I tried to set conditional header ETag value as "*" as below. Thinking it would ignore checking for matching ETag values. But this does not work.

Using Azure.Storage.Blobs package.

        originalETag = properties.ETag;
        blobOpenReadOptions = new BlobOpenReadOptions(true)
            Conditions = new BlobRequestConditions()
                IfMatch = new ETag("*") // set as *, thinking this will ignore etag value when I read blob content and not throw error

               //IfMatch = ETag.All
               //IfNotMatch = originalETag

And used the 

    using (var stream = await blob.OpenReadAsync(offset, segmentSize)) 
            await blob.OpenReadAsync(blobOpenReadOptions);
            stream.Position = offset;
            stream.Read(buffer, 0, buffer.Length); // ERROR in this line
            ret.Byte = buffer;

Read() error below:

    Azure.RequestFailedException: The condition specified using HTTP conditional header(s) is not met.
    Status: 412 (The condition specified using HTTP conditional header(s) is not met.)
    ErrorCode: ConditionNotMet
    <?xml version="1.0" encoding="utf-8"?><Error>
    Server: Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0
    x-ms-request-id: b84cc30f-501e-009f-4596-29524000000
    x-ms-client-request-id: 70f94258-163a-464c-879f-437d5ac7be7
    x-ms-version: 2021-10-04
    x-ms-error-code: ConditionNotMet
    Date: Mon, 16 Jan 2023 10:37:48 GMT
    Content-Length: 252
    Content-Type: application/xml

       at Azure.Storage.Blobs.BlobRestClient.Download(String snapshot, String versionId, Nullable
       at Azure.Storage.Blobs.Specialized.BlobBaseClient.StartDownloadAsync(HttpRange range, BlobRequestConditions conditions, DownloadTransferValidationOptions validationOptions, Int64 startOffset, Boolean async, CancellationToken cancellationToken)
       at Azure.Storage.Blobs.Specialized.BlobBaseClient.DownloadStreamingInternal(HttpRange range, BlobRequestConditions conditions, DownloadTransferValidationOptions transferValidationOverride, IProgress`1 progressHandler, String operationName, Boolean async, CancellationToken cancellationToken)
       at Azure.Storage.Blobs.Specialized.BlobBaseClient.<>c__DisplayClass97_0.<<OpenReadInternal>b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Azure.Storage.LazyLoadingReadOnlyStream`1.DownloadInternal(Boolean async, CancellationToken cancellationToken)
       at Azure.Storage.LazyLoadingReadOnlyStream`1.ReadInternal(Byte[] buffer, Int32 offset, Int32 count, Boolean async, CancellationToken cancellationToken)
       at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted[T](Task`1 task)
       at Azure.Storage.LazyLoadingReadOnlyStream`1.Read(Byte[] buffer, Int32 offset, Int32 count)
       at Project.Server.Models.ItemRepository.GetFile(String fileName, Int64 offset, Int64 blobLengthRemaining, Int64 prevContentLen) in C:\Users\Project\Server\Models\ItemRepository.cs:line 221
       at LogViewer.Server.Controllers.ItemController.GetBlobFile(String fileName, Int64 offset, Int64 blobLengthRemaining, Int64 contentLen) in C:\Users\Project\Server\Controllers\ItemController.cs:line 60
       at lambda_method60(Closure , Object )


Thank you.

A set of technologies in the .NET Framework for building web applications and XML web services.
2,585 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
795 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,999 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
1,406 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hoekstra Jelle 486 Reputation points


    Please check the links below.

    • [https://stackoverflow.com/questions/75155542/how-to-ignore-etag-checking-reading-and-writing-to-blob-content
    • [https://azure.microsoft.com/cs-cz/blog/managing-concurrency-in-microsoft-azure-storage-2/

    Hope this helps

    If it does, please accept the answer. (Don't hesitate to ask your questions if you have any)