ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
#r "Newtonsoft.Json"using System.Net;using Microsoft.AspNetCore.Mvc;using Microsoft.Extensions.Primitives;using Newtonsoft.Json;public static async Task Run(HttpRequest req, ILogger log){ string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); int eventId = data?.eventId; string errType = data?.errType; string errMsg = data?.errMsg; string correlationId = data?.correlationId; string workflowId = data?.workflowId; string workflowUrl = data?.workflowUrl; string flowDisplayName = data?.flowDisplayName;var custProps = new Dictionary(){ { "CorrelationId", correlationId}, { "WorkflowId", workflowId}, { "WorkflowUrl", workflowUrl}, { "WorkflowDisplayName", flowDisplayName}};using (log.BeginScope(custProps)){ if (errType=="Debug") { log.Log(LogLevel.Debug, eventId, $"{errMsg}"); } else if (errType=="Critical") { log.Log(LogLevel.Critical, eventId, $"{errMsg}"); } else if (errType=="Warning") { log.Log(LogLevel.Warning, eventId, $"{errMsg}"); } else if (errType=="Trace") { log.Log(LogLevel.Trace, eventId, $"{errMsg}"); } else if (errType=="Error") { log.Log(LogLevel.Error, eventId, $"{errMsg}"); } else { log.LogInformation($"Event is {eventId}, type is {errType}, and msg is {errMsg}"); } }; string responseMessage = $"This HTTP triggered function executed successfully. {errType} - {errMsg}"; return new OkObjectResult(responseMessage);}
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task Run(HttpRequest req, ILogger log)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
int eventId = data?.eventId;
string errType = data?.errType;
string errMsg = data?.errMsg;
string correlationId = data?.correlationId;
string workflowId = data?.workflowId;
string workflowUrl = data?.workflowUrl;
string flowDisplayName = data?.flowDisplayName;
var custProps = new Dictionary()
{
{ "CorrelationId", correlationId},
{ "WorkflowId", workflowId},
{ "WorkflowUrl", workflowUrl},
{ "WorkflowDisplayName", flowDisplayName}
};
using (log.BeginScope(custProps))
{
if (errType=="Debug")
{
log.Log(LogLevel.Debug, eventId, $"{errMsg}");
}
else if (errType=="Critical")
{
log.Log(LogLevel.Critical, eventId, $"{errMsg}");
}
else if (errType=="Warning")
{
log.Log(LogLevel.Warning, eventId, $"{errMsg}");
}
else if (errType=="Trace")
{
log.Log(LogLevel.Trace, eventId, $"{errMsg}");
}
else if (errType=="Error")
{
log.Log(LogLevel.Error, eventId, $"{errMsg}");
}
else
{
log.LogInformation($"Event is {eventId}, type is {errType}, and msg is {errMsg}");
}
};
string responseMessage = $"This HTTP triggered function executed successfully. {errType} - {errMsg}";
return new OkObjectResult(responseMessage);
}