For a recent project I was working on these are the tools that worked best for what we were looking to accomplish. In the next few blog posts, I’ll detail how I set up my dev environment to accomplish these tasks. The first post takes us from scratch to a default express.js installation running on an Azure Web site.
Before going through this, I’m going to assume a few things.
- You’ve already installed Node and NPM on your Mac
- You’ve already installed Express.js via NPM
- You’ve already signed up for a free trial Azure account
Once you’ve got these ready, your good to go.
Connecting to Azure from the command line
There are two ways to set things up in Azure, the web, and the command line. Since I try and spend more time in Terminal than a web browser (less distractions 🙂 ) I tend towards using the command line. Microsoft has made this relatively painless with the Azure CLI NPM package. To install it, just run the command:
npm install azure-cli -g
Once that installs, you have a very nice and useful set of commands to interact with your azure account. To start, you’ll need to get your publish profile by issuing the following command:
azure account download
Which will open your browser and have you log into your account to download the profile. Once you log in, it will download and then you can start using it by running:
azure account import [path to where you downloaded the file]
Now your ready to go 🙂
Creating your new Azure web site
Now that you can interact with Azure, let’s actually do something. To create your a new azure web site run the command:
azure site create [new site name] —git
This will create you a new azure web site, and also set it up for git development while also setting up the current directory to be a git repo with the azure remote entry already added.
Creating the default express.js web site
Creating a new express site is down the same way as it always is, running the command:
After it runs, you can make sure it runs locally by running:
And launching node:
After ensuring that it is running locally, by pointing your browser at http://localhost:3000 you are ready to push your creation to the cloud. To do this, all you have to do is commit it to your local git repo
git add . git commit -m “initial checkin”
And then push it to the azure remote repo:
git push azure master
And that’s it, you’re live in the cloud! To show your new site in the browser, you can use the CLI shortcut
azure site browse
The ever-expanding world of web dev tools is an unending list of possibilities to make your life as a developer easier. Never has it been easier to mix and match tools and practices to find what works best for you and you project.
This post originally published at blog.4mkapps.com