Azure Blob SAS URL 403 issue - azure

I have a very weird issue with the azure blob. I have an Image container whose blob I am accessing using SAS URL.
"https://{storageName}.blob.core.windows.net/{container}/target_6ace5a78-83a9-4579-b348-2d0097aa1873/a85b8a1c-41c7-42f4-b8cb-a6389cd4cb2a?sp=rwdl&st=2019-02-14T10:25:00Z&=2020-02-16T10:25:00Z&sv=2018-03-28&sig={signatureKey}&sr=c"
When I am using the above URL in my browser its giving 403 but When I am modifying the above URL as below it's working fine. The only change is its now encode ie & is replaced with &
"https://{storageName}.blob.core.windows.net/{container}/target_6ace5a78-83a9-4579-b348-2d0097aa1873/a85b8a1c-41c7-42f4-b8cb-a6389cd4cb2a?sp=rwdl&st=2019-02-14T10:25:00Z&=2020-02-16T10:25:00Z&sv=2018-03-28&sig={signatureKey}&sr=c"
I am not able to understand the issue, because without encoded url also some of the other container SAS URL are working fine, but in this particular container why I need to have an encoded URL.?

So the reason you're getting a 403 error in the first URL is because you're missing se parameter in your URL. If you change your URL to:
"https://{storageName}.blob.core.windows.net/{container}/target_6ace5a78-83a9-4579-b348-2d0097aa1873/a85b8a1c-41c7-42f4-b8cb-a6389cd4cb2a?sp=rwdl&st=2019-02-14T10:25:00Z&se=2020-02-16T10:25:00Z&sv=2018-03-28&sig={signatureKey}&sr=c"
Your request should work just fine.
Regarding why your 2nd URL is working is because the storage service is completely ignoring the query string as the blob container doesn't have a Private ACL. So if you just copy and paste the following URL:
"https://{storageName}.blob.core.windows.net/{container}/target_6ace5a78-83a9-4579-b348-2d0097aa1873/a85b8a1c-41c7-42f4-b8cb-a6389cd4cb2a"
You should see the the blob is downloading.

Related

Unable to access Azure container through browser

This is the error showing in browser when I hit the url of container:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
ResourceNotFound
The specified resource does not exist. RequestId:3fc3c275-301e-000f-3193-f99692000000 Time:2022-11-16T08:13:12.8837824Z
But I am able to access the blob when I hit the URL of blob.
I tried to reproduce the Same in my environment in got the same error as below:
To resolve this issue, try to give access in container url with SAS token like below:
And generate a SAS token and include it in below Url:
https://<storage-account-name>.blob.core.windows.net/<containername>?restype=container&comp=list&<sas-token>
When I ran the same, I got the result successfully like below:
Right click to your container folder and then select change access level and you are done!

Download a file from sas token

I have created a storage_account with a container named data.
In that container I have a single .zip file.
I'm generating an Account Key SAS Token with Read permission directly on the data container :
The Blob SAS URL looks like this :
https://<STORAGE_ACCOUNT>.blob.core.windows.net/data?sp=r&st=2022-06-06T15:23:31Z&se=2022-06-06T23:23:31Z&spr=https&sv=2020-08-04&sr=c&sig=<SIGNATURE>
How am I supposed to download my zip file from that URI?
I'm always running into some Authorization error whereas I though having the link was enough and unfortunately documentation didn't help me to figure out what's wrong.
I would like to download the file from a HTTP call, not using az copy or powershell.
from your description and the URL you provided, I guess the issue is that you didn't reference the name of the zip file in the URL
so instead of
https://<STORAGE_ACCOUNT>.blob.core.windows.net/data?sp=r&st=2022-06-06T15:23:31Z&se=2022-06-06T23:23:31Z&spr=https&sv=2020-08-04&sr=c&sig=<SIGNATURE>
try
https://<STORAGE_ACCOUNT>.blob.core.windows.net/data/zipName?sp=r&st=2022-06-06T15:23:31Z&se=2022-06-06T23:23:31Z&spr=https&sv=2020-08-04&sr=c&sig=<SIGNATURE>

Error in calling Azure rest API -The requested URI does not represent any resource on the server

i am calling Azure Rest API to list all blobs in a directory (inside container) throuh informatica cloud using web service transformation.But i am getting error while running the mapping InvalidUriThe requested URI does not represent any resource on the server.
API: https://<account_name>.blob.core.windows.net/training?restype=container&comp=list&prefix=training/Type/Class
Could not reproduce your issue, the REST API - List Blobs works fine on my side.
You could refer to the sample below, make sure you are using it the same as mine.
Note: When you using prefix, you have already used the container name training in the url, don't use it again in the parameter, it should be prefix=Type/Class.
Request URL:
GET https://accountname.blob.core.windows.net/training?restype=container&comp=list&prefix=Type/Class
Request header:
x-ms-version = 2019-12-12
Test in the postman:
My storage structure:

What actions do you need to stitch together to get a blob into an Azure Files path (File Copy or File Create action)

Using logic apps and event grid, I have no problem triggering event and getting blob properties, but how do I feed this into an Azure file server?
I can see the blob object, the url and so on. I can use Compose action to get the URL. When I pass the URL into a Copy File action of the Azure File object, it gives me a 404 that the file doesn't exist (hence the http 404 response code). Do I need to getBlobContent into a variable and write that to a file? Do I need to use the create SAS URI from the blob path and then use the SAS URI? The latter is what you'd do if you were sending a "click here to get blob" file link to a colleague. But my thought is that the Blob object exists as an accessible object when the trigger occurs (event grid see a file created in the stroage account). Documentation is not helping me.
For this requirement, you need to get the blob content first, then use "Create file" action to create it in your file server. Please refer to my logic app below:
In my logic app, I get the blob content with the path of the blob. Since you mentioned yo have got the url of the blob, so think you can substring the url and get the path. And then put the path into the "Blob" box of the "Get blob content" action.
I have had similar issues and found the 404 was regarding the formatting of the dynamic path returned from the blob.
I ended up (after a lot of hair pulling) stripping out the path using Compose and a bit of hard coded text in a "Get blob content using path" action.
Essentially (this is for my use case which was pulling json files out of blob into a LA workspace, but parts may be applicable for yourself)
Get Subject (from the Eventgrid blob trigger action)
Compose
Inputs - (Subject)
Get Blob content using path
Blob path - /directory/substring(...)
Infer Content Type - NO
(The Substring expression here I am using is - substring(outputs('Compose'), x) where x is the number of characters before my hardcoded directory in the path.
Then -
Initialize variable
Name - BlobContentAsText
Type - String
Value - File Content (from Get blob content using path)
Then -
Send Data (Preview)
JSON Request Body - BlobContentAsText
Custom Log Name - Logs_CL

Azure Video Indexer - Problem Uploading Video From Blob URL with SAS Token

I'm trying to automatically pass videos uploaded into my Azure Blob to the Azure Video Indexer Services using the Upload Video API here: https://api-portal.videoindexer.ai/docs/services/Operations/operations/Upload-Video/console
My problem is that if I pass the video_url parameter as a blob url + the SAS access token, the API returns an error
{
"ErrorType": "INVALID_INPUT",
"Message": "Url content type 'application/xml' is not supported. Only audio and video files are supported. You can find the supported
}
But if I upload the same video to a hosting service that gives me a direct URL to the video file, and then use that URL, it works.
The API call looks like this:
POST https://api.videoindexer.ai/trial/Accounts/{Account_ID}/Videos?name={Video_Name}&privacy=Private&videoUrl=https://{Azure_Blob_Video_URL}.mp4?{sas_token}&indexingPreset=Default&streamingPreset=Default&sendSuccessEmail=False&accessToken={access_token} HTTP/1.1
Host: api.videoindexer.ai
x-ms-client-request-id: 1012ac93-bbbb-cccc-aaaa-edf520fa7e8c
Ocp-Apim-Subscription-Key: {api_key}
Please note that if I paste the blob url + SAS token into the browser, the video plays fine, and the network tab in Chrome's Dev Tools shows that the content type is video/mp4
So how can I get the blob URLs to work?
Thank you
I think the combination that you make here is somehow incorrect.
https://{Azure_Blob_Video_URL}.mp4?{sas_token}
Porbably after combining this it returns 404 with XML saying Blob Not Found.
Try encoding the blob URL as the special signs in the SAS string might be the problem.
Or make it your last variable in the URL.
POST https://api.videoindexer.ai/trial/Accounts/{Account_ID}/Videos?name={Video_Name}&privacy=Private&indexingPreset=Default&streamingPreset=Default&sendSuccessEmail=False&accessToken={access_token}&videoUrl=https://{Azure_Blob_Video_URL}.mp4?{sas_token}
For anyone still running into this problem, I solved it by replacing the each & in the sas token with %26. %26 is the URL escape token. For other escape tokens check:
https://docs.microfocus.com/OMi/10.62/Content/OMi/ExtGuide/ExtApps/URL_encoding.htm

Resources