Skip to content

Instantly share code, notes, and snippets.

using Integration.Observability.Constants;
using Microsoft.Extensions.Logging;
using System;
namespace Integration.Observability.Extensions
{
/// <summary>
/// ILogger extensions for structured logging using typed signatures.
/// </summary>
public static class LoggerExtensions
namespace Integration.Observability.Constants
{
/// <summary>
/// Constants used for Logging and Tracing
/// </summary>
public class LoggingConstants
{
/// <summary>
/// To identify the tracing span checkpoints (e.g. start or finish of each span)
/// Enum values follow the structure spanId + checkPoint
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using ServerlessRequestBin.DurableFunctions.Models;
namespace ServerlessRequestBin.DurableFunctions
{
function Upload-FileToWebApp($resourceGroupName, $webAppName, $slotName = "", $localPath, $kuduPath){
$kuduApiAuthorisationToken = Get-KuduApiAuthorisationHeaderValue $resourceGroupName $webAppName $slotName
if ($slotName -eq ""){
$kuduApiUrl = "https://$webAppName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath"
}
else{
$kuduApiUrl = "https://$webAppName`-$slotName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath"
}
$virtualPath = $kuduApiUrl.Replace(".scm.azurewebsites.", ".azurewebsites.").Replace("/api/vfs/site/wwwroot", "")
traces
| sort by timestamp desc
| where customDimensions.EventId > 1
| where customDimensions.LogLevel == 'Error'
| project EventId = tostring(customDimensions.EventId)
| summarize Count = count(EventId) by EventId
//Change the pEntityId to get the traces for a particular business document
let pEntityId = "2000";
traces
| sort by timestamp desc
| where customDimensions.EventId > 1
| where customDimensions.prop__CheckPoint == 'Publisher'
| where customDimensions.prop__EntityId == pEntityId
| project Level = customDimensions.LogLevel
, PublisherEventId = customDimensions.EventId
, PublisherEventDescription = customDimensions.prop__EventDescription
//Properties used with Azure Functions structure logging are logged as customDimensions.prop__{name}
//To filter events created by our custom structured logging, get only those traces where EventId > 1
//To correlate different checkpoints, we use the CorrelationId
traces
| sort by timestamp desc
| where customDimensions.EventId > 1
| where customDimensions.prop__CheckPoint == 'Publisher'
| project Level = customDimensions.LogLevel
, PublisherEventId = customDimensions.EventId
, PublisherEventDescription = customDimensions.prop__EventDescription
//Properties used with Azure Functions structure logging are logged as customDimensions.prop__{name}
//To filter events created by our custom structured logging, get only those traces where EventId > 1
traces
| sort by timestamp desc
| where customDimensions.EventId > 1
| project Level = customDimensions.LogLevel
, EventId = customDimensions.EventId
, CheckPoint = customDimensions.prop__CheckPoint
, CorrelationId = customDimensions.prop__CorrelationId
, Description = customDimensions.prop__Description
{
"version": "2.0",
"logging": {
"logLevel": {
"default": "Information"
},
"aggregator": {
"batchSize": 100,
"flushTimeout": "00:00:10"
},
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.IO;
namespace PacodelaCruz.AzureFunctions.Logging
{
public static class ProcessOrder