Cannot access Windows azure file storage document
Asked Answered
U

3

10

I have created a file storage in Windows azure and uploaded some documents.

This is what my path to my file looks like https://mySite.file.core.windows.net/notes/txt.pdf

When I try to access the a file from my storage i get this error: enter image description here

Unpremeditated answered 27/1, 2016 at 19:5 Comment(2)
Can you please edit your question to show the code where you're trying to connect to your file storage and access a file? Really impossible to diagnose, as-is.Thrombo
An alternative is 'Azure static website' which stores data in blobsMormon
K
9

This is intended behavior. Please note that there's no anonymous access allowed for files stored in file storage. The access needs to be authorized. Since you're trying to access the resource without being authorized, you're getting this error.

One way of authorizing the access is to create a Shared Access Signature (SAS) on a file/share level with Read permission and then using that SAS URL to access the file.

Krug answered 27/1, 2016 at 19:20 Comment(4)
So where exactly this SAS can be created?Carnauba
It can be created via code or via the azure portal when you have the storage account open.Glottochronology
@ScottChamberlain It looks like it is greyed out. Do you remember if you had to do anything to get the token?Relly
Allowed service type had to be checked.Relly
C
4

This is happening because you are trying to access the file as an anonymous user. If you DO want to give access to anonymous users then create a SAS token and include that token in the URL:

  1. On Azure Portal: go to your storage account, then click on "Shared access Signature" and copy the SAS token:

Azure Portal, Storage Accounts, Shared access signature, SAS token

  1. add the SAS token to your URL: https://mySite.file.core.windows.net/notes/txt.pdf?sv=2017-11-09&ss=f&srt=o&sp=r&se=2018-11-13T19:11:42Z&st=2018-11-13T11:11:42Z&spr=https&sig=5Q7RPkCGiUdQQsAS43qrWvniK8O7Cwc4uLjHFJfTtkc%3D
Castorena answered 13/11, 2018 at 11:27 Comment(2)
The Generate SAS and connection string button is greyed out.Relly
@Relly you need to select an "Allowed resource type" before you can createTelpher
P
0

Here's what worked for me:

Use NuGet package

"WindowsAzure.Storage"

instead of

"Microsoft.WindowsAzure.Storage"

In my case, blob.Exists() and blob.AcquireLease() would give me the HTTP Header exception (despite having the storage key/connection string available). The 2 packages above have the same API's (mostly), but the later gave me issues.

Pergola answered 13/12, 2017 at 1:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.