Skarlinski
Skarlinski

Reputation: 2479

Access azure file storage from web app without a backend

Is there a way to access azure storage via Rest Api, using only frontend javascript?

e.g:

  1. User tries to load an image stored in azure storage .

  2. Redirected to portal.azure.com for logging in.

  3. Sent back to my webapp, with the cookies or whatever is needed to generate an authenticated url.

Upvotes: 2

Views: 740

Answers (1)

Tony Ju
Tony Ju

Reputation: 15629

You can authenticate access to Azure blobs using Azure Active Directory.

Then you will be able to get an access token to access azure storage via Rest Api. Here is an example walks you through how to login a user and acquire a token to be used for Microsoft's Graph Api. You can change the Graph Api to storage api.

Updates:

The way to get access token. The scope can be https://storage.azure.com/.default

enter image description here

Access private blob with access token. You also need to add the x-ms-version header.

enter image description here

Upvotes: 2

Related Questions