I am trying to retrieve a file(File type: csv or xml) by REST API from Azure File Storage, I have Storage Account Name & Key
e.g. account: testgetfilestorage PW:ABC/abc82abc93f80 YCKJH23YGOabcabcabcabcbacbabcbabcabcbabcabcbacmZQ==
I use the "Microsoft Azure Storage Explorer" tool can view & download files successfully, but I test it on Postman was not successful, there is an error: view error image
----------------------------------
Following is my setting on Postman
In Header:
x-ms-version: 2014-02-14
In URL:
GET https://testgetfilestorage.file.core.windows.net/integration/TestFile.xml
I can 100% sure the file exists on File Shares, but the error return 404. May I know anything I did wrong? Thanks
CodePudding user response:
All requests to Azure File Storage must be authorized. The reason you are getting the 404 error is because the requests are not authorized.
If you are using account name/key, you have two options:
Create Authorization header and include
Authorization
header in your request. Steps to compute authorization header is described here: https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key.Use Shared Access Signature. Instead of using authorization header, you can create a Shared Access Signature (SAS) token on the file and use that SAS token as part of the request URL. Steps to compute SAS token for a storage resource is described here: https://docs.microsoft.com/en-us/rest/api/storageservices/create-service-sas. You can also create a SAS token on the file using Storage Explorer or Azure Portal. When creating SAS token, please ensure that it has at least
read
permission.