This project is an Azure Function that sends SMS messages using the Twilio API.
- Node.js and npm
- Azure Functions Core Tools
- An Azure account
- A Twilio account
- Clone this repository.
- Run
npm install
to install the dependencies. - Set up your Twilio account and get your Account SID, Auth Token, and a Twilio phone number.
- Update the
local.settings.json
file with your Twilio Account SID, Auth Token, and phone number.
- Start the function with
npm start
. - Send a POST request to
http://localhost:7071/api/SMSTrigger
with a JSON body containingnumber
andmessage
fields. For example:
{
"number": "<YOUR_PHONE_NUMBER>",
"message": "Ahoy, world!"
}
curl request example:
curl -m 70 -X GET http://localhost:7071/api/SMSTrigger/ \
-H "Content-Type: application/json" \
-d '{
"message": "Ahoy from Azure Functions.",
"number": "<YOUR_PHONE_NUMBER>"
}'
Run the twilio-azure-function-create.sh
script to create a new Azure Function App and associated resources.
Deploy the function to Azure with func azure functionapp publish <FunctionAppName>
, replacing <FunctionAppName>
with the name of your Function App.