Let's Get this Bread! Using Azure Functions to Make Sourdough
Tags: javascript, webdev, beginners, tutorial
Published: 2020-04-03 03:40:25

---
title: Let's Get this Bread! Using Azure Functions to Make Sourdough
published: true
description: How to use the power of Azure Functions to remember to feed your sourdough starter
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/os2tytgkd3zclv0jwu8i.png
tags: javascript, webdev, beginners, tutorial
---

*This post (co-created with [Sophia Li](https://twitter.com/sophia_wyl)) will walk you through how to use Azure Functions, VSCode, and Twilio to create a text thread between you and your sourdough baby to make sure you feed it in a timely manner.*

*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? Sophia is job searching! You can [contact her on Twitter](https://twitter.com/sophia_wyl) or check out [her website](https://sophiali.dev/) if you’re interested in chatting with her (seriously- hire her before someone else snatches her up- SHE BAKES AMAZING BREAD, Y'ALL! 🥖🍞🥯).*

*Happy coding! -💕 Chloe*

*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!*

A couple months ago, I met Sophia Li at our Bootcamp Office Hours hosted at the SF Reactor (now coming to you [remotely every Wednesday](https://www.youtube.com/watch?v=SDMgMo977G0)!). At our office hours, I get to meet a wide range of folks from different backgrounds looking to make a career transition into tech. From former teachers, fitness instructors, to folks from the Marines- it's not uncommon to meet folks from all walks of life at the [SF Microsoft Reactor](https://developer.microsoft.com/en-us/reactor/). Of course, when Sophia told me she was working part-time at a local bakery I knew that we *kneaded* to build a project together involving two of my favorite things: Azure Functions & bread. 🥖🍞🥯

![oprah loves bread gif](https://media.giphy.com/media/3o7ZeFpK0qqSpsWNsA/giphy.gif)

If you're on Twitter I'm sure you've seen the many **many** posts from tech folks regarding their precious Sourdough starter children. Here's a fun image I saw on [/bayarea Reddit](https://www.reddit.com/r/bayarea/comments/fmspma/neighbor_giving_out_sourdough_starter_for_corona/) just this week:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2q8h4c2cjxtipmj5cwe0.png)

While I have yet to make my own sourdough at home (unfortunately, supplies are a bit low in the East Bay at the moment) Sophia informed me that a problem she and others often face is forgetting to feed their babies (of the bread variety, of course! 😉). With shelter in place mandates and physical distancing to lower the curve, we have a lot less toilet paper and staples like bread in the stores, and a lot more time at home. Consequently, this has resulted in a rise of sourdough baking, and the key to making sourdough bread is starter.

Here's a fun Tweet by the hilarious [Danielle Baskin](https://twitter.com/djbaskin) that highlights the *rise* of sourdough home bakers:

{% twitter 1242806395281354752 %}

Starter is live wild yeast used to make sourdough bread. You can make it in your own home with a few ingredients and some time! Making starter is a week-long process that involves a chemical reaction between the combination of flour, water, and air. On the first day, you mix flour and water in a jar and let it sit out with the lid slightly ajar. After 24 hours, on day two, you discard about 95% of your original starter, and replace it with a mix of equal parts water and flour. You repeat this process for an entire week, and at the end of the week, you have a bubbly and active starter ready to make you some bread. Here's a video on [how to make your own starter](https://www.youtube.com/watch?v=sTAiDki7AQA).

Here's what starter looks like at a production scale:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gko120c5p51585r2pucd.jpg)

To keep your starter alive and healthy, you need to feed it every 24 hours. If you forget to feed it long enough, then, well... it dies 😵. So it's important that we remember to feed it! Let's set up a text message reminder to feed your starter baby so you can keep it bubbly and active to make sourdough bread.



### 🛠 To get started, let's set up a few tools.
1. [Azure account](https://azure.microsoft.com/?WT.mc_id=breadchloe-devto-chcondon): We'll set up a free Azure account so we can run our code without having to worry about application infrastructure. You can read more about [Azure Functions here](https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview/?WT.mc_id=breadchloe-devto-chcondon).
2. [Twilio account](www.twilio.com/referral/QYHnll): Twilio is a platform that enables communication between devices and apps through their cloud communications API. We'll sign up for their free trial to get a number that we can use to text ourselves.
3. [Visual Studio (VS) Code](https://code.visualstudio.com/docs/azure/extensions/?WT.mc_id=breadchloe-devto-chcondon): We'll be using VS Code for our text editor because we need to use the Azure Extension. You can download it for free from the [VS Code Marketplace](https://code.visualstudio.com/docs/azure/extensions/?WT.mc_id=breadchloe-devto-chcondon).


# Let's Get to the Code! 👩🏼‍💻

👩‍💻 Now that we have our tools, let’s get coding.

#### 1. Create a Function App in your Azure portal. 
![red box highlighting Function App](https://dev-to-uploads.s3.amazonaws.com/i/r23woeorx2ok6gnk7tvc.png)
To get started, we'll create a function in our Azure portal by selecting Create a new Resource and then creating a new Function App. You'll need to fill out some basic information to set up your Function. These are some of the options I chose in my setup:
- Resource Group: sourdough-timer 
- Function App name: sourdough-timer
- Runtime: Node.js
- Version: 12
- Region: West US 2 (I'm in California, choose your location)
- Operating System: Linux


#### 2. Create a Timer trigger function in VS Code.
![red box to highlight lightning bolt with green plus sign](https://dev-to-uploads.s3.amazonaws.com/i/n4a2e7kp3x71iakncukp.png)
Before we start coding, make sure you're signed into your Azure account in VS Code. Once you're logged in, navigate to your Azure Extension and create a new function (lightning bolt with green plus sign). We'll select the [Timer trigger](https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer/?WT.mc_id=breadchloe-devto-chcondon) template for our Function. For my setup, I chose JavaScript as my language. I also set the [CRON expression](https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=csharp#ncrontab-expressions/?WT.mc_id=breadchloe-devto-chcondon) to `0 0 15 * * *`, which translates to 8:00AM Pacific Time for me. This is when our text message will get sent. 

Once our project is created, we'll use this Timer trigger code template.
{% gist https://gist.github.com/sophi-li/0bc7440095b59aaf7386ad6521b5b3b6 %}

#### 3. Save our Twilio credentials and numbers to Azure Functions
Next, we'll need to save the following information:
- TWILIO_SID - You can find your account SID on your Twilio home page.
- TWILIO_TOKEN - Your can find your token on your Twilio home page.
- SENDER_NUMBER - Your Twilio number.
- RECIPIENT_NUMBER - Your cell phone number. 

To keep our information secure, let's save it under Azure's configuration settings so we can access it in our environment. It'll look like this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mua7xicjmmjt6jrrbj1z.png)

We'll access our Twilio credentials and numbers in our code by calling our variables with `process.env`, which gives us access to all existing environment variables:
{% gist https://gist.github.com/sophi-li/73878061fbf5dd81dce146ec0601d48d %}

#### 4. Install the Twilio module
Now that we have our Twilio credentials saved and ready to go, we need to install the [Twilio module](https://www.twilio.com/docs/sms/quickstart/node) so our scripts can use it.

Open up your terminal and run: `npm install twilio`

If you don't already have npm installed, [here are some instructions](https://www.npmjs.com/get-npm).

#### 5. Add our text message and phone numbers
Next, we're going to add the message and our phone numbers. 

For `to` and `from`, we'll put our `RECIPIENT_NUMBER` and `SENDER_NUMBER` variables, respectively. As a reminder, we saved our numbers in our Azure configurations so we could access our numbers in the environment with `process.env`. This keeps our information secure because we don't have to type our numbers directly in our code which may end up in a public repository. 

Now we can add a message to remind ourselves to feed our baby starter in `body`. I put "Don't forget to feed me!". 

Here's the template code for adding our text message:
{% gist https://gist.github.com/sophi-li/3bae88881d35407c4a53be34259a3210 %}


#### 6. Deploy it!
![red box to highlight the blue arrow deploy button](https://dev-to-uploads.s3.amazonaws.com/i/i2jh6dl922fv2zii6ywv.png)
Now you have everything you knead, deploy your code by selecting the deploy button in VS Code (blue arrow button). You might have to wait a minute or two for your first deploy. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/00s7t6z0wvvop0aoqwld.png)
Once it's finished deploying, let's switch over to our Azure portal and click run to test out our Timer trigger. 

Here's a screenshot of what it looks it:
![screenshot of text message from Martha saying "Don't forget to feed me!"](https://dev-to-uploads.s3.amazonaws.com/i/l70wgsi0ze2oqbwfg4x6.PNG)

Congratulations, your Timer trigger function worked! 🎉 Now you'll start getting text message reminders to feed your starter at your scheduled time. 

If you need to put your sourdough baking on pause, you can put your starter in the fridge. To turn off the text message reminders, you can stop your Azure function. And when you're ready to make sourdough again, take your starter out of the fridge and feed it. Don't forget to turn on your Timer function again!

To see the full code, check Sophia's [GitHub repo here](https://github.com/sophi-li/sourdough-timer).

Here's a quick video of her shaping sourdough bread when she was a baker apprentice at one of the best bakeries in San Francisco! 😍🍞 With the help of your text message reminders, your starter will be ready in a week and you'll be ready to make sourdough bread!

{% youtube gumE-sVgMKw %}

If you have any sourdough tips or photos of your sourdough, leave a comment.

Happy coding and happy baking! 👩‍💻🍞

P.S. Enjoy this wholesome (grain) [Twitter thread](https://twitter.com/ChloeCondon/status/1245824558944251906) of bread children of Twitter! 🥖🍞🍼

{% twitter 1245824558944251906 %}