We built this using the Azure portal + VSCode and is intended for students and learners new to Azure. You can of course build this however you'd like! These particular steps have been written for those new to our portal + VSCode (with lots of visuals to help you along the way!).
Love this post? Hiring? I'm job searching! You can contact me on Twitter or check out my website if you’re interested in chatting (seriously- hire me before someone else snatches me up- I also bake amazing sourdough bread! 🥖🍞🥯).
Happy coding! -✨ Sophia
P.S. There's a bit of a preamble here to give context on this project. If you'd like to skip to the code, scroll down to "Let's Get to the Code! 👩🏼💻" below!
Before my visit to Kennedy Space Center, space (and NASA specifically) felt like something far, far, away- almost untouchable by anyone other than the few and brave astronauts and scientists that made our US launches successful and possible. In elementary school I'd be green with envy over the kid contestants on Double Dare and Legends of the Hidden Temple who'd win grand prizes to space camp for completing obstacle courses. 🏆
Believe it or not, this was the ultimate in cool for a young child of the 90s, but alas, I attended theatre & horse camp instead...
As a theatre kid with ADHD (++ a dash of dyscalculia to add some fun 🧮), I had always assumed working with NASA was something completely unattainable. Unless I could somehow convince my parents to allow me to compete on Family Double Dare, there was no way I'd ever get close to touching anything space or NASA related. Not to mention the fact I had never seen or heard of anyone who looked/acted/sounded like me doing anything with NASA.
Until I watched the film Hidden Figures and learned about Katherine Johnson, and started following folks like Bianca and Molly on Twitter, NASA (and space related things, for that matter) felt like something men in white lab coats did. And while I do own a lab coat (for Dexter's Lab cosplay reasons) I definitely did not see myself or identify with anyone I saw in pop-culture working on space related things.
Turns out that's far from the truth! Believe it or not, doing cool things with NASA requires way less math, astronaut training, and eating space food than you think (although, that space ice cream stuff they have in museum gift shops is pretty tasty! 🍦).
I was lucky enough to once again attend a NASA Social event- this time, with 2 of my favorite women in STEM: the aforementioned and incredibly talented Bianca and my coworker (+ BFF) April! This time, instead of a launch, we visited Armstrong Flight Research Center in Palmdale California and learned all about the five new NASA Earth science airborne campaigns getting ready to take to the field in 2020! 🌍🛩🌊🛰
For those unfamiliar with NASA, you may be puzzled to hear they would have such a focus on Earth science (vs. the usual coverage of other planets, space travel, etc). However, knowing about our own home planet's behavior and health is just as important as learning what's beyond it! You can learn more about each mission in detail here, but here's a brief summary of the 5 missions discussed at this event:
☃️ Intense Snowfall Events
IMPACTS (the Investigation of Microphysics and Precipitation for Atlantic Coast-Threatening Snowstorms), will study how snow is distributed in the clouds. This is the first major field campaign to study East Coast snowstorms in 30 years (and is particularly exciting since the instrumentation on the aircrafts used to test this has madesignificant advancement since then!
🌡 Ocean-Atmosphere Heating
Ever heard of an "eddie"? Nope, not this kind. They are circular currents of water that facilitate the exchange of heat between the ocean and the atmosphere and the vertical transport of nutrients, oxygen, and dissolved gases in the upper ocean. Researches using the S-MODE (Sub-Mesoscale Ocean Dynamics Experiment) will make these observations 200 miles off the coast of San Francisco.
🌊 River Deltas and Sea Level Rise
Coastal deltas act as nurseries for fish, crustaceans and other animals, in addition to protecting our infrastructure against hurricanes and tsunamis. The Delta-X mission will provide scientists with data to better understand sea level rise (most major deltas are sinking under and disappearing) and understand and determine if they can mitigate the impacts of the very important coastal resources the deltas provide.
☁️ Aerosols Changing Clouds
ACTIVATE (the Aerosol Cloud Meteorology Interactions Over the Western Atlantic Experiment) will measure a broad range of aerosol, cloud and meteorological conditions. Using a NASA Falcon and King Air, researchers will be measuring these conditions, providing them with a more comprehensive measurement to draw definite conclusions about the effects of these interactions.
⛈ When Strong Storms Punch into the Stratosphere
DCOTSS (or Dynamics and Chemistry of the Summer Stratosphere) will be targeting intense storms to investigate that form over the central US in the Summer months. NASA's ER-2 high-altitude aircraft (that can fly 70,000 feet, significantly higher than most research aircraft can go!) as well as weather satellites and ground-based radar, will help us "learn how these storms affect today's stratosphere, and how their impacts might change as the atmosphere changes in coming decades” according to Ken Bowman, DCOTSS principal investigator from Texas A&M University.
I learned so many things during my 2 visits to NASA, but by far the biggest takeaway has been this: NASA is basically the grandfather of space open source™️. I used to view NASA as a big powerful organization with top secret vaults, men in astronaut suits, and imposing dudes with ear pieces talking about space things in their top secret space offices with their secret space phones. And while sure, there are many classified things and behind the scenes at NASA that we don't (and may never 👽🤫🛸) get to see, a majority of NASA's research, data, and findings are publicly available for all to use.
Which is how this project was born! I met Sophia when she attended our Bootcamp Office Hours at the SF Microsoft Reactor. We bonded over our non-traditional backgrounds and shared love of bread (blog post involving this coming VERY soon! 🥖🍞). This project was really fun to create together since Sophia was a complete newbie to Azure Functions before this project! We hope you enjoy this project and getting your sea-legs (er- space-legs? 🤔🚀) with Twilio, Azure, and the many many open NASA APIs available to you!
To follow this tutorial, you’ll need a few things:
Azure Functions make it possible to get projects up and running very quickly, without worrying about spinning up a server. We’ll be triggering our function with an Azure Functions Timer, but there are many other ways to execute (for other examples, check out other posts on my Dev.to!). If you’ve never worked with Azure before, this Microsoft Learn tutorial on creating your first function could be helpful, and you can dive into the docs too.
Create a Twilio account, and add a trial phone number that can receive SMS and MMS.
This might’ve been obvious, but you’ll also need your cell phone handy for texting/testing your app. 🤳
We'll be using VSCode in this tutorial and using its Azure Functions extension. Never used VSCode before? Totally confused by what an extension is? 🤯😰 Don't worry- we have docs for that! Also, check out the intro video below.
Head over to the NASA API website and generate an API key (keep this handy- we'll need it later to communicate with the Earth!).
We'll be using the EPIC API (Earth Polychromatic Imaging Camera) in our example, but you're welcome to use any NASA API you'd like!
Ok- that was a lot of set-up.
Now that we have all the tools we need, let's get to coding!
For the sake of easy to understand visuals/screenshots I used the Azure portal to create this. You can also use VS Code, the Azure CLI, etc. With Azure Functions you are given the the ability to code and test Functions locally on your machine without having to deploy to the cloud every single time you want to test (a huge time saver!).
To create an Azure Function, you can just start from the Get Started menu and select Function App in the Azure portal.
Then you’ll need to fill in some basic info about your function here. Including the app name, the Azure subscription you’d like to use, a resource group (I’m creating a new one in this case), the Operating System you’d like to use, the hosting plan (I’m using consumption), the location I’d like to use (I’m in California, so West US 2 is usually my default), the runtime stack I’d like to use (I’m using NodeJS in this case), and I have the option to create new storage or use existing. I created a new one in this case.
Click though until you reach the Review & Create page, and when you're ready click create!
Once you have a lay of the land, go ahead and add the Azure Functions VSCode Extension.
Once your function is deployed, head over to VSCode and find your function.
Once you've clicked though all of these options, create and open your VSCode project.
In your index.js file, add the following code (don't worry- we'll walk through this in sec!):
You'll notice we have a couple variables here that have not been defined! We want to keep our Twilio credentials, phone numbers, and API keys safe (and secret!)... lucky for us, there's a simple way to do this in Azure using the portal!
Navigate over to Configuration and add the following with their values: TWILIO_TOKEN + TWILIO_SID (these can be found on the main page of your Twilio account), SENDER_NUMBER (your Twilio #), RECIPIENT_NUMBER (your number), and your NASA API key (which can be generated here). Once you save these, we'll almost be ready for launch! 🚀
There are a couple additional things we'll need for our app to work. In your VSCode terminal install Twilio with the following command:
npm install twilio
And then install node-fetch with the following:
npm install node-fetch --save
We're almost there! As a final step, let's deploy the work we did in VSCode to Azure!
Click the deploy button (as shown above- the blue arrow pointing up). You may get some alerts confirming the difference in version here- click through these (we're just confirming our VSCode version differs from the current version in our Azure portal).
If all goes well, and your deployment was successful, it's time to...
Now it's time to see our Azure Function in action! Click the Run button on your Azure Function in the Azure portal to test things out! Your text should look a lil somethin' like this:
For extra fun, add your Twilio phone # to your contacts, so you know the Earth is hitting up your phone with a selfie each day (errr... is it a selfie if the Earth doesn't have hands so NASA took it? 🤔🌎🤳 lol).
If your text sent successfully- congrats! You now will have a daily text from Earth (ok, it's technically the NASA API, but we can pretend!).
As always- please reach out with any questions in the comments below ⤵️- Chloe and I are here to help! We look forward to hearing about all the amazing things you build with the NASA API + Azure Functions, and hope you enjoy the daily pics of our beautiful planet ♥️🌎
Claim your page on DEV before someone else does
Level up every day