I want to implement a feature to upload recorded audio blob data to the azure blob storage in frontend(react.js). I have azure storage connection string, but I dont want to my connection string to be exposed in frontend. Is there any way to define an backend API to generate token(which has expiration time) from azure credentials so that I can use it in the Frontend? Do I need additioinal settings from azure account?
Ps. similar to this one. For azure speech cognitive sdk, there is a api to issue tokens using speech region and speech key. https://{SPEECH_REGION}.api.cognitive.microsoft.com/sts/v1.0/issueToken
I tried to use sas token but it seems to be very complex.
Yes, you can create a backend API to generate a SAS token for your Azure Blob Storage account. This way, you can keep your connection string and account key secure on the server side and only expose the SAS token to the front end.
you can use the below code to upload audio files using the sas token from the backend.
First, create a backend directory to generate sas-token.
Package:
server.js
Start the backend API by running the following command in the
backenddirectory:Now front end uses the React app.
Package:
AudioUploader.js
Output:
Browser:
Portal:
Here is my GitHub link to upload audio files to Azure blob storage with backend API using javascript.