I read Ted Neward's article about deploying a simple Node.js app to Microsoft Azure and wanted to give it a try.
The steps mostly worked, except for a few issues. Below are the steps that he lays out. I am assuming that you have clicked the link and read the article. He does a much better job explaining everything. In this post, I wanted to note the changes necessary with the steps.
- In a local directory, create the following Javascript file. This file creates a basic web server using Node.js.
var http = require('http'); var port = process.env.PORT || 3000; http.createServer(function(req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World'); }).listen(port);
In the article, this script is named "helloHTTP.js." For the file to work in Azure, it needs to be named "server.js". - Test the script using Node.js
- Run the script using Node.js:
node server.js
- Open the URL http://localhost:3000 in your browser.
- You should see the string "Hello World".
- Run the script using Node.js:
- Install the azure-cli tools:
npm install -g azure-cli
- Access your Azure account:
azure account download
- Import the file that was just downloaded:
azure account import
- Create the site with git:
azure site create --git
In the article, the argument for the git option only showed a single dash. Also, this step will prompt you for a site user name and region. The name you choose must be unique across Azure. Pay attention to the messages too. It will give you the full URL necessary for accessing the site once it is created. - Add the script file:
git add server.js
- Commit the file:
git commit -m "Initial site creation."
- Push the site to Azure:
git push azure master
No comments:
Post a Comment