Azure Functions has its own opinionated way of developing applications based on triggers, input bindings and output bindings. Azure supports two Twilio products using output bindings: Twilio Programmable Messaging for sending SMS and Twilio SendGrid for sending emails.
In this tutorial, you'll learn how to send text messages with C# .NET using Azure Functions and Twilio binding.
You will need these items to follow along:
- OS that supports .NET (Windows/Mac/Linux)
- .NET 6 SDK
- Azure Functions Core Tools
- A code editor or IDE (Recommended: VS Code with C# plugin, Visual Studio, or JetBrains Rider)
- A free Twilio account (If you register here, you'll receive $10 in Twilio credit when you upgrade to a paid account!)
Get started with Twilio
You will need to set up a couple of things with Twilio before developing the Azure function:
- If you don't already have a Twilio phone number, go and buy a …
One of my favourite features of Azure Functions v2 and above is the ability to include a
Startup class. Why is this cool you may ask? Well, it means that you can use .NET Core's built-in Dependency Injection (DI). This then means that project architecture can look remarkably like ASP.NET Core web apps. DI also makes testing easier as dependencies can be mocked. In this post, I'll show you how you can quickly add DI to an Azure Function.
Note: Azure Functions v3.0 became GA in January 2020. This means that you can now use .NET 3.1 and Node 12 in your Azure Functions. They still don't support the new
System.Text.Json but that should come in time.
If you would like to see a full integration of Twilio APIs in a .NET Core application then checkout this free 5-part video series I created. It's separate from this blog post tutorial …