All Projects → Azure-Samples → storage-blobs-node-quickstart

Azure-Samples / storage-blobs-node-quickstart

Licence: MIT License
Code for QuickStart article for accessing Blobs with Node JS

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects
page_type languages products description urlFragment
sample
javascript
azure
You are viewing a tutorial for the legacy version of the Azure Storage Node.js SDK.
storage-blobs-node-quickstart

Storage Blobs Quickstart

WARNING Samples in this repository use older package azure-storage for Azure Storage Blobs. We recommend that you refer to the samples that use the new package @azure/storage-blob instead.

The following sample includes the following features:

  • Uses async/await: The Azure Storage SDK API is still callback-based, but the approach in this sample modernizes the syntax. API calls are wrapped in Promises and are executed in the context of an async/await operation.

  • Uses environment variables: This sample accesses the connection string from an environment variable. The use of environment variables is representative of how you would access sensitive information in production.

To run this sample, you need an Azure account, a blob storage account, and the associated blob storage connection string.

Set up

First, clone the repository on your machine:

git clone https://github.com/Azure-Samples/storage-blobs-node-quickstart.git

Then, switch to the appropriate folder:

cd storage-blobs-node-quickstart

Next, install the dependencies:

npm install

Now, add your blob storage connection string as an environment variable named AZURE_STORAGE_CONNECTION_STRING to a file named .env.

Note: This repository includes a file named .env.example. You can rename this file by removing .example and adding the correct value for your connection string in the .env file.

Running the sample

Once the setup, you can run the sample by using npm start.

npm start

When complete, the application should produce output similar to the following:

Containers:
 - container-one
 - container-two
Container "demo" is created
Blob "quickstart.txt" is uploaded
Local file "./readme.md" is uploaded
Blobs in "demo" container:
 - quickstart.txt
 - readme.md
Blob downloaded blob content: "hello Blob SDK"
Blob "quickstart.txt" is deleted
Container "demo" is deleted
Done

Resources

You can use the Azure Storage Explorer to see the data in your Azure account.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].