Azure Storage Browser



  1. Azure Storage Access Via Browser
  2. Azure Storage Browser Windows 10
  3. Azure Storage Explorer Browser

The demand for the Azure Storage Client Library for Node.js, as well as your feedback, has encouraged us to work on a browser-compatible JavaScript library to enable web development scenarios with Azure Storage. With that, we are now releasing the preview of Azure Storage JavaScript Client Library for Browsers. Enables web development scenarios. I appreciate this is a couple of years old now - but I'm coming up against this issue when downloading multiple files and zipping them. I provide SAS Urls for single file downloads - works great, but when a user wants to download, say 100 image files, I don't want to provide 100 SAS URls to the browser to download, I want to consolidate them in to a zip file.

Uploading Files to Azure Blob Storage from the Browser

As part of an ongoing project I’ve been trying to upload files from from the browser to an ASP.NET Core MVC site, however there appears to be a hard limit preventing uploading files greater than ~28.6 MiB in size which I can’t manage to figure out a way around.

As one of the eventual destinations for these files was to be as a blob in Azure Storage there’s happily a set of JavaScript libraries from Microsoft (though these are still in preview) designed to interact with Azure Storage objects which I can use for this and which aren’t affected by size limits.

Azure Storage Account

Display contents of an Azure storage container via web browser. Ask Question Asked 4 years, 4 months ago. Active 4 years, 4 months ago. Viewed 3k times 7. First post at stack so be nice:) I've created an Azure storage account with a container in it. I've set the container access policy to 'Container'. I've created an Azure storage account with a container in it. I've set the container access policy to 'Container'. I have added a file to that storage container and can browse to that. However when I browse to the actual container path I get a 404.

The first step is to create a container in your storage account (as detailed here). Once the container has been created you need to create a CORS rule in it to allow the JavaScript running in the browser to access it. For testing purposes I set everything to “*” but this should be locked down when going live.

JavaScript Libraries

The GitHub project that contains the Azure Storage JavaScript library is here, in order to use it in your project you’ll need to download the client libraries from here and include the relevant ones in your project.

Web Application

The code for my test web app is here with the processing taken care of by the JavaScript the controller methods are unnecessary and so the below in Index.cshtml is all that’s required. It’s based on the example here.

The SAS token for this was generated by an Azure Function I created which creates short-lived SAS tokens, an easier option might be to just create a long-lived SAS token in Storage Explorer, store it in the site appsettings.json and access it from there.

In this sample, we will demonstrate common scenarios for Azure Blob Storage that includes creating, listing and deleting containers and blobs.

Azure Blob storage is a service for storing large amounts of unstructured object data, such as text or binary data, that can be accessed from anywhere in the world via HTTP or HTTPS. You can use Blob storage to expose data publicly to the world, or to store application data privately.

Note: You may need set up a HTTP server to host this sample for IE11 and latest Chrome.

Contents:

Step 1: Preparing an Azure Storage account with CORS rules set

Cross-origin resource sharing, or CORS, must be configured on the Azure Storage account to be accessed directly from JavaScript in the browser. You are able to set the CORS rules for specific Azure Storage account on the Azure Portal. The 'Allowed origins' could be set to '*' to allow all the origins in this sample. For more information about CORS, see Cross-Origin Resource Sharing (CORS).

Azure Storage Browser

Step 2: Importing Azure Storage JavaScript Client Library

Importing azure-storage.blob.js in your HTML file for blob operations.

Step 3: Creating an Azure Storage Blob Service Object

The BlobService object lets you work with containers and blobs. Following code creates a BlobService object with storage account and SAS Token.

You can load Azure Storage JavaScript Client Library in a CommonJS or AMD environment by JavaScript module loaders. If no module system is found, global variable AzureStorage.Blob will be set, which is the start point where we can create service objects for blob and access to the storage utilities.

How to get full detailed API definitions? Currently, the JavaScript Client Library shares almost the same API definitions with Node.js SDK, besides Node.js runtime specific APIs. Please check API details on Azure Storage API reference documents. The JavaScript global variable AzureStorage.Blob is just like the object require('azure-storage') returns in Node.js, but limits to Blob related interfaces. Go to BlobService to view possible methods provided by BlobService class.
Warning: Azure Storage JavaScript Client Library also supports creating BlobService based on Storage Account Key for authentication besides SAS Token. However, for security concerns, we recommend use of a limited time SAS Token, generated by a backend web server using a Stored Access Policy.

Step 4: Container Operations

A container provides a grouping of blobs. All blobs must be in a container. An account can contain an unlimited number of containers. A container can store an unlimited number of blobs. Note that the container name must be lowercase. BlobService object provides plenty of interfaces for container operations.

List Containers

BlobService provides listContainersSegmented and listContainersSegmentedWithPrefix for retrieving the containers list under a storage account.

Create Container

BlobService provides createContainer and createContainerIfNotExists for creating a container under a storage account.

Delete Container

BlobService provides deleteContainer and deleteContainerIfExists for deleting a container under a storage account.

Executable Example

The sample will try to create an Azure Storage blob service object based on SAS Token authorization. Enter your Azure Storage account name and SAS Token here, and executable examples in following steps dependent on the settings here. Make sure you have set the CORS rules for the Azure Storage blob service, and the SAS Token is in valid period.

In the following executable example, you can try to list all the containers under your storage account settings, and try to create or delete one container from your account.

  • Click button to view the container list under your Azure Storage account

  • Click button to create a container under your Azure Storage account:

  • Click 'Delete' button in the container list to delete the container under your Azure Storage account

  • Click 'Select' button to select and operate with the blobs in next step

Step 5: Blob Operations

Blob: A file of any type and size. Azure Storage offers three types of blobs: block blobs, page blobs, and append blobs.

Block blobs are ideal for storing text or binary files, such as documents and media files. Append blobs are similar to block blobs in that they are made up of blocks, but they are optimized for append operations, so they are useful for logging scenarios. A single block blob can contain up to 50,000 blocks of up to 100 MB each, for a total size of slightly more than 4.75 TB (100 MB X 50,000). A single append blob can contain up to 50,000 blocks of up to 4 MB each, for a total size of slightly more than 195 GB (4 MB X 50,000).

Azure Storage Browser

Page blobs can be up to 1 TB in size, and are more efficient for frequent read/write operations. Azure Virtual Machines use page blobs as OS and data disks.

For details about naming containers and blobs, see Naming and Referencing Containers, Blobs, and Metadata.

List Blobs

BlobService provides listBlobsSegmented and listBlobsSegmentedWithPrefix for retrieving the blobs list under a container.

Upload Blob

BlobService provides createBlockBlobFromBrowserFile, createPageBlobFromBrowserFile, createAppendBlobFromBrowserFile and appendFromBrowserFile for uploading or appending a blob from an HTML file in browsers.

Uploading blob from stream. You can set up the blob name as well as the size of this uploading session.

Checking the upload progress with speedSummary object.

Warning: By default, the speedSummary.getCompletePercent() only updates progress when a block is uploaded to server. There are 2 default settings that may influence the upload progress display.
  • blobService.singleBlobPutThresholdInBytes is the maximum size (default 32MB), in bytes, of a blob before it must be separated into blocks.
  • Option {blockSize: SizeInBytes} of blobService.createBlockBlobFromStream() is the size (default 4MB) of every block in the storage layer.
This means, by default, blobs smaller than 32MB will only get the progress update when the upload is over, and blobs larger than 32MB will update the process every 4MB. For slow connections or progress reporting for small blobs, you can customize both the two settings into samller values such as 1MB or 512KB. Thus the progress will update with the smaller step you set. However, very small block sizes will impact the storage performance especially for a large blob.

Download Blob

BlobService provides interfaces for downloading a blob into browser memory. Because of browser's sandbox limitation, we cannot save the downloaded data trunks into disk until we get all the data trunks of a blob into browser memory. The browser's memory size is also limited especially for downloading huge blobs, so it's recommended to download a blob in browser with SAS Token authorized link directly.

Shared access signatures (SAS) are a secure way to provide granular access to blobs and containers without providing your storage account name or keys. Shared access signatures are often used to provide limited access to your data, such as allowing a mobile app to access blobs. The following code example generates a new shared access policy that allows the shared access signatures holder to perform read operations on the myblob blob, and expires 100 minutes after the time it is created.

Note: You can choose to use the SAS Token in browser side, or generate a temporary SAS Token dynamically in your server side with Azure Storage C# or Node.js SDKs etc. according to your security requirements.

Delete Blob

BlobService provides deleteContainer and deleteContainerIfExists for deleting a blob under a storage account.

Azure Storage Access Via Browser

Executable Example

After clicked the 'Select' button on the container list in last step, you are able to operate with the blobs under the selected container.

  • Click button to view the blobs under your selected container

  • Click button to upload a local file to current container after selecting a file:

  • Click 'Delete' button to delete the blob

  • Click 'Download' link to download a blob to local

Step 6: Creating your JavaScript Application based on Azure Storage JavaScript Client Library

Azure Storage Browser Windows 10

  1. Setting CORS rules for your selected Azure-Storage account blob service.
  2. Including functional file(s) needed, such as 'azure-storage.blob.js' for blob operation.
  3. Using keyword 'AzureStorage.Blob' to access to Azure storage JavaScript APIs for blobs.
  4. Referring to API documents for detailed API definitions.

Azure Storage Explorer Browser

You can view the source code of this sample for detailed reference.