- Azure Serverless Computing Cookbook
- Praveen Kumar Sreeram
- 196字
- 2021-07-02 20:23:10
Customizing the log file name using IBinder interface
- Navigate to the code editor of the RegisterUser function.
- 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
)
- 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;
- 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);
}
- Let's run a test using the same request payload that we have used in the previous recipes.
- 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:

推薦閱讀
- Mastering JavaScript Functional Programming
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- Mastering C# Concurrency
- Reactive Programming With Java 9
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Keras深度學習實戰
- 硅谷Python工程師面試指南:數據結構、算法與系統設計
- Instant Lucene.NET
- Mastering C++ Multithreading
- Learning Material Design
- Spring技術內幕:深入解析Spring架構與設計原理(第2版)
- PrimeFaces Blueprints
- Kotlin Programming By Example
- 交互式程序設計(第2版)
- Mastering JavaScript