Showing posts with label Node.js. Show all posts
Showing posts with label Node.js. Show all posts

Accessing Azure Table Storage in Node.js Applications

Microsoft Azure Storage services provides features of storing NoSQL data in the Table Storage. The Azure Table Storage stores schema-less data using Key/Value pairs. Since the data store is schema-less, we can use Table Storage to store the data for those applications that are designed and targeted to flexible data capture. Although the data is stored as schema-less, it is easy to query the data using simple querying mechanism.

You can consider using Table storage where you need not to use complex joins, stored procedures for any data operations. 

Table Storage and Creating Resource Group and Storage Account


Following are some of the features of Azure Table Storage
  • Table is a collection of entities. These entities does not enforce any schema. This provides a flexibility to store data for different set of properties for entities.
  • Entity is a set of properties. Conceptually we can map an entity with a table row on relational database. The max size of entity in Table is 1 MB.
  • Property is a name/value pair. We can have max 252 user defined properties in entity and along with these there are 3 system properties present in entity. These properties are RowKey, PartitionKey and Timestamp.
  • PartitionKey, this is the key based on which the data in the Table Storage is stored in logical partition. This provides query optimization while retrieving data from table storage.
  • RowKey, is the unique identification of the entity in the table storage.        
To use Azure Storage, we need a Microsoft Azure Subscription. Please visit this link to create a free subscription. Make sure that you read all features and limits of using Azure Free Subscription. Once you have a subscription, login to the portal and you can start using its features.

Creating Web Applications using MERN Stack

MongoDBMongoDB is a cross-platform document-oriented database program. It is a NoSQL Database. The data is stored in JSON document format and this database can store images in Base64 encoded format. More information on MongoDB can be read from this link.


Express.js: This is a Web Application Framework for Node.js. We can use this for building REST APIs and also for building Web Applications. More information on Express.js can be read from this link.

React.js makes it painless to create modern front-end applications. This library provides an easy approach for building interactive views. 

Node.js: This is an open-source, cross-platform JavaScript runtime environment used to run JavaScript code out-of-browser. We use Node.js for server-side JavaScript execution. More information can be read from this link.

The Component is a major building block of a React.js application. Component is the object that contains data, logic and user interface (UI) for the View. We can build an application with complex Views  using React.js components. 

In JavaScript full stack applications, we can use JavaScript object model for End-to-End apps that varies  from UI to Database. We use MongoDB, Express.js, React.js and Node.js for designing such applications, which are collectively also knows as MERN apps. In this article, we will build a complete JavaScript application based on MERN a.k.a the MERN stack.   

Accessing Azure CosmosDB database using Node.js and Express REST APIs

Last week, I was conducting a session on MEAN Stack. In this training, I taught my students how to access MongoDB in an Express application.

One of the attendees asked me to create a demo on accessing CosmosDB using Node.js apps.

In this tutorial, I will show you the steps to do the same.

CosmosDB is a multi-model, globally distributed database service on Microsoft Azure. It provides NoSQL data storage using Table Storage, SQL API, MongoDB, Gremlin, etc. More information on this can be read here https://docs.microsoft.com/en-us/azure/cosmos-db/introduction. I have also written a post on using Azure CosmosDB with ASP.NET Core and Angular. You can read about it over here https://www.dotnetcurry.com/windows-azure/1395/cosmosdb-webapi-angular-client.

In modern web application development  based on Isomorphic apps (pure JavaScript from Client-to-server e.g. MEAN/MERN Stack), the data storage is preferred as NoSQL data store. On  top of that, if this data store is provided and managed by and on cloud, then such storage services are highly preferred.

Dockerizing a Node, Express and MongoDB Application

In this tutorial, we will dockerize a Node,Express and Mongo Application. We will be using a Docker Linux container.

Let’s first take an overview of Docker and then we will directly jump to the implementation of the application.

What is Docker and why to use it?


When our applications are ready for  deployment, we have to configure a production machine with all the dependencies for the application. This is often a tedious and time consuming job. To make this approach easy, we can make use of Docker.

Docker provides a way to run applications securely and isolated in a container with all the applications dependencies packaged in it. Docker containers wrap up software and its dependencies into a standardized unit for software development. This makes sure that all the dependencies to run the application are packaged so that application will always run.

Some additional advantages of using Docker are:
  1. Once a docker image is created with all its dependencies, you need not worry about the operating system configuration for your application deployment. Since Docker is platform independent, a docker image that has successfully build  can run on any platform using docker.
  2. This docker image can be easily shared with a client (or anyone) who wants to use the application. They can run the application simply by installing docker on their machine.        
Docker can be downloaded from this link.