Node, TypeScript, AzureAD & O365 API Apps on Raspberry Pi

At Microsoft Build and Ignite, a Node.js web app demo integrated TypeScript, AzureAD, ADAL, & Office 365 APIs to run on any platform.

Last week at the Microsoft Build conference & this week at Microsoft’s Ignite conference, I presented short express talks / theater sessions on using Node.js to run a web application that integrates TypeScript, AzureAD, ADAL & Office 365 APIs in a neat little demo. If you missed it, you can grab the code from this project in github as well as watch this video of the running demo .

What I find so cool about this approach to building web application is that they can run on any platform with no code changes. I developed the web application using Visual Studio Code on my MacBook Pro where I also tested it, but I also ran it with zero code changes on Windows 8.1, deployed it to an Azure web app & to the Raspberry Pi. The only thing I had to do was tweak the IP of the device in a configuration file & update the reply URL in the AzureAD application to redirect back to the correct host.

When I show this little demo I usually get a bunch of questions. One is what you need to do this. For my demo you only need to buy three things: the Raspberry Pi 2 for about $40, a Wifi USB adapter for about $10 & a 32GB microSD card for about $15… all told, about $65.

The other question I get is how do you do this once you get the hardware. There are a few different things you need to do.

Set up Raspberry Pi & Install Node.js

First step, you need to get an OS on the microSD card & then install Node.js on it. I’ve written about that in a previous blog post here: Set up Node.js on Raspberry Pi 2 B .

Add Node.js Project to the Raspberry Pi

Once that’s done, you need to get the code for the Node.js project on to the microSD card. There are a few different ways you can do this:

  • Connect to the Raspberry Pi via SSH and use git to clone your project to the device… make sure you run npm install to get all the packages the app needs
  • Connect to the Raspberry Pi over SMB file share from your laptop & XCOPY the project & package dependencies over to the device’s microSD card
  • Copy the project & package dependencies to the microSD card by connecting the card to your laptop

Personally the first option is the easiest, but it can take some time to download everything. The last option is pretty easy, just gets to be a pain to move the card between the laptop & Raspberry Pi and then boot the Pi.

Update Configuration File with Raspberry Pi’s IP

Last but not least, if you are building an app like what I’ve done in my sample that uses AzureAD for authentication, you will need to get the IP of the device and set it in a configuration file as well as update the application in AzureAD so once the user logs in, they are redirected to the website running on the device.

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment