Customizing the log file name using IBinder interface

Perform the following steps:

  1. Navigate to the run.csx file of the SendNotifications function.
  2. Remove the TextWriter object and replace it with the variable binder of the IBinder type. The following is the new signature of the Run method with the changes highlighted:
#r "SendGrid"
#r "Newtonsoft.Json"
#r "Microsoft.Azure.WebJobs.Extensions.Storage"
using System;
using SendGrid.Helpers.Mail;
using Newtonsoft.Json;
using Microsoft.Azure.WebJobs.Extensions.Storage;
public static void Run(string myQueueItem,
out SendGridMessage message,
IBinder binder,
ILogger log)

  1. We have removed the TextWriter object, and the outputBlob.WriteLine(emailContent); function will no longer work. Let's replace it with the following piece of code:
        using (var emailLogBloboutput = binder.Bind<TextWriter>(new 
BlobAttribute($"userregistrationemaillogs/
{objInsertedUser.RowKey}.log")))

{
emailLogBloboutput.WriteLine(emailContent);
}
  1. Let's run a test using the same request payload that we used in the previous recipes.
  2. You can see the email log file that is created using the RowKey of the new record stored in the Azure Table storage, as shown in the following screenshot: