Deploying Socket.IO App to Windows Azure Web Site with Azure CLI
In this blog post, I will demonstrate how to deploy Socket.IO app to Windows Azure Website using Windows Azure Cross-Platform Command-Line Interface, which leverages the Windows Azure Website’s new support for Web Sockets. Recently Windows Azure has announced lot of enhancements including the support for Web Sockets in Windows Azure Websites, which lets the Node.js developers deploy Socket.IO apps to Windows Azure Websites. In this blog post, I am using Windows Azure CLI for create and deploy Windows Azure Website.
Install Windows Azure CLI
The Windows Azure CLI available as a NPM module so that you can install Windows Azure CLI using NPM as shown in the below command.
After installing the azure-cli, just enter the command “azure” which will show the useful commands provided by Azure CLI.
Import Windows Azure Subscription Account
In order to import our Azure subscription account, we need to download the Windows Azure subscription profile. The Azure CLI command “account download” lets you download the Windows Azure subscription profile as shown in the below command. The command redirect you login to Windows Azure portal and allow you to download the Windows Azure publish settings file.
The account import command lets you import the downloaded publish settings file so that you can create and manage Websites, Cloud Services, Virtual Machines and Mobile Services in Windows Azure.
Create Windows Azure Website and Enable Web Sockets
In this post, we are going to deploy Socket.IO app to Windows Azure Website by using the Web Socket support provided by Windows Azure. Let’s create a Website named “socketiochatapp” using the Azure CLI.
The above command will create a Windows Azure Website that will also initialize a Git repository with a remote named Azure. We can see the newly created Website from Azure portal.
By default, the Web Sockets will be disabled. So let’s enable it by navigating to the Configure tab of the Website, and select “ON” in Web Sockets option and save the configuration changes.
Deploy a Node.js Socket.IO App to Windows Azure
Now, our Windows Azure Website supports Web Sockets so that we can easily deploy Socket.IO app to Windows Azure Website. Let’s add Node.js chat app which leverages Socket.IO module. Please note that you have to add npm module dependencies in the package.json file so that Windows Azure can install the dependencies when deploying the app. Let’s add the Node.js app and add the files to git repository.
Let’s commit the changes to git repository.
We have committed the changes to git local repository. Let’s push the changes to Windows Azure production environment.
The successful deployment can see from the Windows Azure portal by navigating to the deployments tab of the selected Windows Azure Website.
The screen shot below shows that our chat app is running successfully.
You can follow me on Twitter @shijucv