官术网_书友最值得收藏!

Customizing the log file name using IBinder interface

  1. Navigate to the code editor of the RegisterUser function.
  2. Remove the TextWriter object and replace it with the variable binder of type IBinder. This is the new signature of the Run method with the changes highlighted:
        public static void Run(HttpRequestMessage req, 
TraceWriter log,
CloudTable objUserProfileTable,
out string objUserProfileQueueItem,
out Mail message,
IBinder binder,
out SMSMessage objsmsmessage
)
  1. Let's grab the data of the new record that's inserted into the Azure Table storage service. We will be using the GUID (RowKey) of the newly created record in the Table storage. Make the changes highlighted in the following piece of code:
        TableResult objTableResult = 
objUserProfileTable.Execute(objTblOperationInsert);
UserProfile objInsertedUser =
(UserProfile)objTableResult.Result;
  1. As we have removed the TextWriter object, the line of code outputBlob.WriteLine(emailContent); 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 have used in the previous recipes.
  2. You will 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:
主站蜘蛛池模板: 邵东县| 上虞市| 宣恩县| 勃利县| 仁怀市| 三河市| 江永县| 伊宁县| 呼伦贝尔市| 玉林市| 贵德县| 宁蒗| 中卫市| 和硕县| 海晏县| SHOW| 莆田市| 始兴县| 黄冈市| 九江市| 黎川县| 泉州市| 灌云县| 呼玛县| 乌兰浩特市| 江都市| 全椒县| 静海县| 镇雄县| 广德县| 宜城市| 城市| 孝昌县| 阜阳市| 伊宁市| 临桂县| 和田县| 新余市| 五指山市| 司法| 黄山市|