37

I am trying to access the URL given in Azure for a file on the Azure File Storage format, however I am getting this error below. Is it possible to get this? Why would they offer a public URL when it's useless? Also how can I access this directly from IIS?

<Error>
<Code>InvalidHeaderValue</Code>
<Message>
The value for one of the HTTP headers is not in the correct format. RequestId:5d681103-0a1a-00cc-5555-5s4849000000 Time:2016-02-04T14:06:50.1786949Z
</Message>
<HeaderName>x-ms-version</HeaderName>
<HeaderValue/>
</Error>
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
  • 1
    Please see if this answers your question: http://stackoverflow.com/questions/35045880/cannot-access-windows-azure-file-storage-document/35046177#35046177 – Gaurav Mantri Feb 04 '16 at 14:11
  • 4
    Why event have a public URL then? – Mike Flynn Feb 04 '16 at 18:03
  • It is a URL and not a public URL. Furthermore, you can create a Shared Access Signature (say with read permission), append it to the URL and then you should be able to access the file directly. – Gaurav Mantri Feb 04 '16 at 18:05
  • 4
    Then how can we make a public url e.g. www.websitename.com which could open that index file from our hosting? – meDeepakJain Dec 14 '16 at 05:22
  • Did you ever find a solution to this? – spuder Feb 21 '17 at 17:15
  • I had the same error message when using `New-AzRmStorageShare`, when I'd included the `-AccessTier` parameter. Dropping that parameter, all worked as expected. – JohnLBevan Jun 11 '21 at 07:53

5 Answers5

33

Gaurav already mentioned a similar question here where it says you should use a "Shared Access Signature". In your storage account settings in Azure you'll find a topic "Shared Acess Signature". After clicking "Generate SAS" you'll get a "SAS Token" which you need to append to your URL.

Shared Access Signature

Community
  • 1
  • 1
K232
  • 1,040
  • 14
  • 36
  • Instead of generating SAS token, it's recommended to generate a SAS derived from Stored Access Policy. May refer to the [steps given here](https://stackoverflow.com/a/69566546/4311268). – Tommy Leong Oct 14 '21 at 07:23
11

If you use Azure File service to share your files, you have to add SAS token after your resources URL. e.g. https://testiiju5zra.file.core.windows.net/alexaskillaudio/lamb.mp3?sv=SDFCSGDJ01231%&SDDFXsuSDFSDSDSSFD

Alternatively, you can do the exact same things by using Azure Blobs as well. If you use Blobs, you don't have to add the extra token after resources URL. Just create a container on Blobs and make it public. And you can access your file like
https://testiiju5zra.blob.core.windows.net/blobaudiosource/lamb.mp3

Andy Lai
  • 1,714
  • 1
  • 14
  • 17
  • 2
    What if I want to make an azure file share public without the token. A lot of my calls will be http gets from web pages where I am not able to append this token – johnstaveley Sep 03 '18 at 07:23
7

Mike,
The error you received indicates that you are missing x-ms-version header. But once you set it, you will receive another error if you have not authenticated. You can refer to https://msdn.microsoft.com/en-us/library/azure/dn194274.aspx for list of required headers. Alternatively, you can use client library for the requests instead of REST API.

2

Try to use a blob instead. Here is an article how to set it up.

https://learn.microsoft.com/en-gb/azure/storage/blobs/storage-blob-static-website-how-to?tabs=azure-portal

Robert Moszczynski
  • 1,081
  • 2
  • 16
  • 26
1

This error is also caused by missing/incorrect connection string in local.settings.json file

Your file should like this:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=xxxxxx;AccountKey=xxxx;EndpointSuffix=core.windows.net",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}
user160357
  • 865
  • 10
  • 14