Azure File Storage Error: Condition Headers Are Not Supported
Asked Answered
L

6

9

When attempting to download a PDF file to a browser directly from Azure File Storage I get this error:

<Error>
    <Code>ConditionHeadersNotSupported</Code>
        <Message>
            Condition headers are not supported. RequestId:a84ee68e-   001a-001b-4223-bff5e7000000 Time:2017-04-27T06:57:22.2002199Z
        </Message>
</Error>

Edge: Blank page or blank page with frozen loading indicator.

FireFox: Second time, shows dialog to download file.

Chrome: Blank page or When PDF Documents “Open PDF files in default PDF viewer application” setting is checked, shows dialog to download file.

IE: Shows dialog to download file.

Safari: Displays PDF.

The behavior can be seen here:
https://peachstatepca.file.core.windows.net/content/newsletters/PresseApril2017.pdf?sv=2016-05-31&sr=f&sig=rkQEmY6IWXZqcgvhmm00gLQ%2FCZEq6nsH95S3aP9T72A%3D&se=2017-05-01T11:46:18Z&sp=r

Limner answered 30/4, 2017 at 12:54 Comment(0)
B
2

Azure File Storage Error: Condition Headers Are Not Supported

Since the new Edge browser will not have any support for ActiveX plug-ins. Therefore, Acrobat/Reader plug-in won't work with Edge. We can get more details for Change in support for Acrobat and Reader plug-ins in modern web browsers and Microsoft Edge: Building a safer browser.

Edit:

If we try to download the PDF file with Edge in the private and develop mode, we can get the error message "Something’s keeping this PDF from opening" and also can know that edge browser has sent 2 requests. And second request with Header 'If-range'. According the Azure file storage Get File API, there is no specifying Conditional Headers If-Range supported. I also find a similar issue about edge browser.

enter image description here

I also test in the Firefox and Chrome, then just get the 1 request.

enter image description here

Note: For Azure Blob Service, the pdf file can be opened correctly from the edge browser. As Blob Get Blob API that supports a successful operation to read the full blob returns status code 200 (OK) and a successful operation to read a specified range returns status code 206 (Partial Content).

Brest answered 1/5, 2017 at 1:51 Comment(3)
I really think that the issue is with Azure File Storage, not the browser. When PDF files are loaded from the web site file system, they display just fine in all of the browsers. Edge has built-in support for displaying PDF files and does not need a plug-in. Actually, it can be set as the default PDF reader in Windows 10, in that case, there is no need for Acrobat.Limner
I am going to switch to Azure Blob Storage. Everything works fine with that. Thanks for your help.Limner
Please vote on this issue to get it escalated and corrected at the service-side. feedback.azure.com/forums/217298-storage/suggestions/…Turino
A
7

We were also facing this issue and the easiest way, till Azure File Team implements the suggestion given in the Azure Feedback forum, a workaround is to append extra parameter at the end of URL. So, for the above URL -- https://peachstatepca.file.core.windows.net/content/newsletters/PresseApril2017.pdf?sv=2016-05-31&sr=f&sig=rkQEmY6IWXZqcgvhmm00gLQ%2FCZEq6nsH95S3aP9T72A%3D&se=2017-05-01T11:46:18Z&sp=r&xyz=timestamp of client

This will ensure browser is not caching and hence conditional headers will not be added

Abdul answered 21/6, 2019 at 13:46 Comment(0)
C
4

There is noting wrong or any issue with Azure file storage, its because of some proxy/cache server. You can use following solution.

/// token = SharedAccessSignature
    string tick = $"&{ DateTimeOffset.UtcNow.Ticks}";
    Uri url = new Uri(file.StorageUri.PrimaryUri.ToString() + token + tick);
Centonze answered 24/5, 2017 at 10:33 Comment(1)
This will completely eliminate the caching which is not good. Every time the page loads all the images will load again.Urbannal
B
2

Azure File Storage Error: Condition Headers Are Not Supported

Since the new Edge browser will not have any support for ActiveX plug-ins. Therefore, Acrobat/Reader plug-in won't work with Edge. We can get more details for Change in support for Acrobat and Reader plug-ins in modern web browsers and Microsoft Edge: Building a safer browser.

Edit:

If we try to download the PDF file with Edge in the private and develop mode, we can get the error message "Something’s keeping this PDF from opening" and also can know that edge browser has sent 2 requests. And second request with Header 'If-range'. According the Azure file storage Get File API, there is no specifying Conditional Headers If-Range supported. I also find a similar issue about edge browser.

enter image description here

I also test in the Firefox and Chrome, then just get the 1 request.

enter image description here

Note: For Azure Blob Service, the pdf file can be opened correctly from the edge browser. As Blob Get Blob API that supports a successful operation to read the full blob returns status code 200 (OK) and a successful operation to read a specified range returns status code 206 (Partial Content).

Brest answered 1/5, 2017 at 1:51 Comment(3)
I really think that the issue is with Azure File Storage, not the browser. When PDF files are loaded from the web site file system, they display just fine in all of the browsers. Edge has built-in support for displaying PDF files and does not need a plug-in. Actually, it can be set as the default PDF reader in Windows 10, in that case, there is no need for Acrobat.Limner
I am going to switch to Azure Blob Storage. Everything works fine with that. Thanks for your help.Limner
Please vote on this issue to get it escalated and corrected at the service-side. feedback.azure.com/forums/217298-storage/suggestions/…Turino
T
2

Azure File storage doesn't support Conditional Headers at this time.

A workaround is to use the CacheControl property and set it to no-cache, no-store, must-revalidate.

  • You can do this for new files during upload by setting the Properties of the File.
  • For existing files, they can be updated via a Powershell script, or one by one using Storage Explorer. You'll need to clear your browser cache to remove existing cached header information.

Using Storage Explorer to set CacheControl property

Turino answered 4/9, 2019 at 4:2 Comment(0)
B
2

If you are using C# and the Nuget packages then you can do this programatically like so

var sas = fileRef.GetSharedAccessSignature(new SharedAccessFilePolicy()
{
    Permissions = SharedAccessFilePermissions.Read,
    SharedAccessExpiryTime = new DateTimeOffset(DateTime.UtcNow.AddHours(1))
},
new SharedAccessFileHeaders()
{
    CacheControl = "no-cache, no-store, must-revalidate"
});
Bantam answered 1/11, 2019 at 13:49 Comment(0)
I
0

I think you need to set the CORS rule for your share

https://learn.microsoft.com/en-us/rest/api/storageservices/cross-origin-resource-sharing--cors--support-for-the-azure-storage-services

or you might have uploaded an empty file.

Ieyasu answered 18/2, 2018 at 13:7 Comment(1)
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.Saltarello

© 2022 - 2024 — McMap. All rights reserved.