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

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:
主站蜘蛛池模板: 沈阳市| 密云县| 宣汉县| 淳化县| 龙州县| 阳朔县| 锦屏县| 和田县| 杭州市| 彭泽县| 贵阳市| 梅州市| 隆昌县| 湘潭县| 陆丰市| 新津县| 和龙市| 竹山县| 岳阳县| 孝昌县| 诏安县| 衢州市| 巨鹿县| 林西县| 集安市| 宁阳县| 夏津县| 长垣县| 滨州市| 宣化县| 河南省| 青岛市| 宁陕县| 塔河县| 灌阳县| 岗巴县| 沁源县| 江安县| 临西县| 平昌县| 日照市|