How to do it...

Perform the following steps:

  1. Navigate to the Application settings blade of the function app and add two keys to store TwilioAccountSID and TwilioAuthToken, shown as follows:
  1. Go the Integrate tab of the SendNotifications function, click on New Output, and choose Twilio SMS.
  1. Click on Select and provide the following values to the Twilio SMS output bindings. Please install the extensions of Twilio. The From number is the one that is generated in the Twilio portal, which we discussed in the Getting ready section of this recipe:
  1. Navigate to the code editor and add the following lines of code, highlighted in bold. In the following code, I have hardcoded the To number. However, in real-world scenarios, you would dynamically receive the end user's mobile number and send the SMS via code:
        ...
...
#r "Twilio"
#r "Microsoft.Azure.WebJobs.Extensions.Twilio"
        ...
...
using Microsoft.Azure.WebJobs.Extensions.Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

public static void Run(string myQueueItem,
out SendGridMessage message,
IBinder binder,
out CreateMessageOptions objsmsmessage,
ILogger log)
...
...
...
message.AddAttachment(FirstName +"_"+LastName+".log",
System.Convert.ToBase64String
(System.Text.Encoding.UTF8.GetBytes(emailContent)),
"text/plain",
"attachment",
"Logs"
);

objsmsmessage = new CreateMessageOptions(new PhoneNumber
("+91 98492*****"));

objsmsmessage.Body = "Hello.. Thank you for getting
registered.";
}
  1. Now, do a test run of the RegisterUser function using the same request payload.
  2. The following is the screenshot of the SMS that I have received: