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
Related
I have requirement where it has to be done programmatically using POSTMAN REST API, where I have to upload a file/blob to Azure storage account and retrieve the unique URL of the specific file that I have uploaded, and I have to share that URL to third party so that they can view it on browser.
This is what I have done in the POSTMAN
Request:
PUT https://{storage-account-name}.blob.core.windows.net/{container-name}/{file-name}{SAS-token}
Headers:
x-ms-version: 2020-04-08
x-ms-blob-type: BlockBlob
x-mock-response-name: Upload Blob
Body: Attached a file from my local
Response:
I have received 200 code and file is successfully uploaded. However, in the response headers I don't see any URL or unique SAS token that I can share to my third-party client.
I have also tried adding se and sp to sas token, I got the below error
AuthenticationFailed
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:65282b4e-401e-0050-2337-43ee90000000 Time:2023-02-18T01:20:28.3522177Z
**Signature did not match. String to sign used was r 2023-02-18T09:12:15Z /blob/storage-account-name/container-name/file-name.txt 2021-06-08 b **
Note: We don't want to generate SAS token manually from Azure portal for each file and construct the URL and share it to the client due to high traffic coming in. Once it is successful using POSTMAN. I have to implement the same in IBM App Connect enterprise, ESQL coding*
All the suggestions are much appreciated. Thank you in advance.
Retrieve the unique URL of the specific file that I have uploaded programmatically and share that URL with third party so that they can view it on browser.
In addition to the se and sp parameters, the following parameters are required to construct the correct SAS URL:
signed version (sv)
signed resource (sr)
signature
Your error message says that the signature does not match the rest of the URL. Signature a hash-based message authentication code (HMAC) that you compute over the string-to-sign and key by using the SHA256 algorithm, and then encode by using Base64 encoding
You can find how to construct the string-to-sign and signature depending on the version on this documentation page.
Postman has a built-in JavaScript library that can help you to calculate HMAC:
CryptoJS.HmacSHA1("string-to-sign", "key").toString()
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>
I'm trying to create a new container in a Blob Storage account using the Create Container API.
https://myaccount.blob.core.windows.net/mycontainer?restype=container
I can't get this to work, I'm struggling to get the format of the Authorization header right. Other blob services I've used allow this to be passed as a query parameter.
I have the SAS token, similar to ?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2022-02-01T16:52:59Z&st=2021-02-02T08:52:59Z&spr=https&sig=r4%2B7dlSfSO8kyd8mKawHhXNtRzInq7YI%2FIbqSr1g%2FqE%3D
How do I form the Authorization header correctly to pass this?
Thanks.
To create a blob container by using Create Container rest api, if you're using "sas token", then you don't need to add "Authorization" in the Headers.
Assume you have a correct "sas token", then you the request url should look like this(Note: you should remove the first "?" from the "sas token"):
https://myaccount.blob.core.windows.net/mycontainer?restype=container&your_sas_token(note that remove the first ? from sas token)
And in the Headers, you just need pass x-ms-date and x-ms-version.
Here is the test by using Postman:
By the way, here is the screenshot about how to generate the "sas token" for creating blob container:
I tried to use REST API azure cognitive services for speech to text transcription. The resource is created on azure portal with key and endpoint (https://westeurope.api.cognitive.microsoft.com/sts/v1.0/issuetoken)
When I try to create POST request from postman for some audio file form file system I got the error
**404Resource Not Found **
Using Postman I defined URL https://westeurope.api.cognitive.microsoft.com/sts/v1.0/issuetoken/v1?language=de-DE&format=detailed
and created the parameters for language and format
In HeadersI added values for
Ocp-Apim-Subscription-Key:....
Accept:application/json;text/xml
Content-Type: audio/wav;codecs=audio/pcm;samplerate=16000
And in Body I selected binary option and find audio file in folder but after that got error 404?
Is there any missing step in preparing the request for an audio file?
Here are screenshots of steps what I did:
1.
3.
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.