Navigate / search

Sending SMSes from Azure Functions v2 – Twilio

Please find the brief manual to sending SMSed by Twilio service in Azure Functions v2. The purpose of it is similar to text related to SendGrid case.

In case of Twilio, you need to install Microsoft.Azure.WebJobs.Extensions.Twilio NuGet package. After doing it, you should use the following code:

using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

public static class SendNotificationSMS
  public static void Run(
      From = "Assigned by Twilio number",
      Body = "...")]
    out CreateMessageOptions messageOptions)
    messageOptions = new CreateMessageOptions(
      new PhoneNumber("Phone number to which you would like to send message"));

Together with that, you should also add to applications settings two entries with the following name:

  • AzureWebJobsTwilioAccountSid
  • AzureWebJobsTwilioAuthToken

and assign values provided by Twilio.

At the end I would encourage you to see the previous article – Sending SMSes from Azure Functions – Twilio. You will find there a bigger description related to this integrations.

Sending emails from Azure Functions v2 – SendGrid

Some time ago I described how you could integrate SendGrid service with Azure Functions (article: Sending emails from Azure Functions v2 – SendGrid link). Mentioned article is still valid in the scope of SendGrid service configuration. I need to add a part related to integration with Azure Functions v2. This version is generally available from the last few months and it introduced some architectural changes.

In the previous version of functions (v1), the code that has been responsible for integration with different services providers was part of the runtime. Each time when Microsoft wanted to change something related to integration he needed to change the whole functions platform. In the second version of functions code responsible for integration have been moved outside platform. This change allowed us to introduce new services that we will be able to integrate with Azure Functions. Moreover, it changed a bit way how we will use this part in the code. Read more

FluentValidation.Validators.UnitTestExtension version 1.4

I just managed to publish a new version of package FluentValidation.Validators.UnitTestExtension. This package allows you to write unit tests for Fluent Validators in a more effective way.

With version 1.4 following changes have been introduced:

  • new verifiers that check the configuration of EnumValidator, MaxLengthValidator, MinLenghtValidator, ExactLengthValidator, ExclusiveBetweenValidator and InclusiveBetweenValidator
  • support for .NETStandard 1.6 and .NETStandard 2.0

More information about the project is available on GitHub.

How to enable/disable Azure Function programmatically

Today I would like to write about something different. I am curious… Have you ever thought about enabling/disabling Azure Function by code? In such scenario, we would be able to decide about the state of the function directly from our application. I believe that you can find a lot of useful scenarios for such behaviour. I will provide two of them.

The first one. We have some resource that is not so fast and we would like to reduce the frequency of using it during the day. In such scenario, we can use Azure Storage Queue as a buffer for actions to compute. And turn on Azure Function only for a night and then in the morning turn it off again.

Another one is strictly connected with a question that I hear quite often during meetups or hackathons. Are we able to turn off function when we use all free capacity that is provided by Azure? People that are offering some small solution for public access would like to avoid the situation when they will need to pay for it. Read more

How you can improve code quality in your project?

Last Saturday during my lecture about code quality I was a bit shocked how many people didn’t know the most accessible tools that can improve code quality. You should remember that cost of quality improvements will be low only when we will think about those issues from the early beginning of the project. Every additional day when we are not monitoring and improving quality will increase the cost of potential quality issues fixes in future.

Of course, I would assume that each time we are trying to deliver good quality code but we are only humans. So even when we do not have enough budget for refactoring, I would like to advise to start monitoring the quality of code. Then we will be able to check present status of code quality and observe the general trend. It means that we will know where we are in our project. Read more