azure-kusto-nlog-sink
AGENTS.md3 starsChanged 7 months agoMITView on GitHub
This file provides guidance for AI agents (GitHub Copilot, Copilot Workspace, etc.) working on this repository. NLog.Azure.Kusto is an NLog custom target that writes log events to Azure Data Explorer (Kusto). It is published as the NuGet package NLog.Azure.Kusto. E2E tests need environment variables pointing to an Azure Data Explorer cluster: This project uses centralized NuGet package version management. All package versions are defined in: Individual .csproj files reference packages without specifying a version — versions come from Directory.Packages.props. When…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 123
Always pull the latest
main: before creating a new branch: - Distinctive: line 146
Write clear, descriptive commit messages.
- Distinctive: line 148
Use imperative mood or a concise description of the change
- Distinctive: line 150
Keep the subject line under 72 characters
- Distinctive: line 177
Ensure CI passes (build + tests)
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance for AI agents (GitHub Copilot, Copilot Workspace, etc.) working on this repository.
Project Overview
NLog.Azure.Kusto is an NLog custom target that writes log events to Azure Data Explorer (Kusto). It is published as the NuGet package NLog.Azure.Kusto.
- Language: C#
- Framework: .NET 8.0, .NET Standard 2.0, .NET Framework 4.7.2 (multi-target)
- Logging framework: NLog (extends
AsyncTaskTarget) - Ingestion SDK: Microsoft.Azure.Kusto.Ingest
- Testing framework: xUnit
- License: MIT
- Owner: Microsoft / Azure
Repository Structure
├── AGENTS.md # AI agent guidance (this file)
├── README.md # User-facing documentation
├── CODE_OF_CONDUCT.md
├── LICENSE
├── SECURITY.md
├── SUPPORT.md
├── .github/
│ └── workflows/
│ ├── dotnet.yml # CI: build + test on push/PR to main
│ └── nuget.yml # Manual NuGet publish workflow
└── src/
├── Directory.Build.props # Shared MSBuild properties (all projects)
├── Directory.Packages.props # Centralized NuGet package versions
├── NLog.Azure.Kusto.sln # Solution file
├── NLog.Azure.Kusto/ # Main library project
│ ├── NLog.Azure.Kusto.csproj
│ ├── ADXTarget.cs # Core NLog target implementation
│ ├── ADXSinkOptions.cs # Configuration & connection management
│ ├── ADXLogEvent.cs # Log event model for Kusto ingestion
│ ├── AuthenticationType.cs # Authentication mode enum
│ └── AssemblyInfo.cs
├── NLog.Azure.Kusto.Tests/ # Unit & E2E tests
│ ├── NLog.Azure.Kusto.Tests.csproj
│ ├── ADXTargetTest.cs # Unit tests (config loading)
│ ├── ADXSinkE2ETest.cs # E2E tests (requires live ADX cluster)
│ ├── Usings.cs
│ └── config/ # NLog test configuration files
└── NLog.Azure.Kusto.Samples/ # Sample console application
├── NLog.Azure.Kusto.Samples.csproj
├── Program.cs
└── NLog.configBuild & Test
Prerequisites
- .NET 8.0 SDK or later
Build
dotnet restore src
dotnet build src -c ReleaseRun Unit Tests
dotnet test src -c ReleaseRun E2E Tests (requires live ADX cluster)
E2E tests need environment variables pointing to an Azure Data Explorer cluster:
# Linux / macOS
export CONNECTION_STRING="<your-kusto-connection-string>"
export DATABASE="<your-database-name>"
# Windows PowerShell
$env:CONNECTION_STRING="<your-kusto-connection-string>"
$env:DATABASE="<your-database-name>"Then run:
dotnet test src -c Release --verbosity normalRun the Sample
dotnet run --project src/NLog.Azure.Kusto.SamplesDependency Management
This project uses centralized NuGet package version management. All package versions are defined in:
src/Directory.Packages.propsIndividual .csproj files reference packages without specifying a version — versions come from Directory.Packages.props. When updating a dependency, always update it in Directory.Packages.props, not in individual .csproj files.
Key Dependencies
| Package | Purpose |
Microsoft.Azure.Kusto.Ingest | Azure Data Explorer ingestion client |
NLog | NLog logging framework |
Microsoft.NET.Test.Sdk | .NET test platform SDK |
xunit | xUnit testing framework |
xunit.runner.visualstudio | xUnit VS Test adapter |
coverlet.collector | Code coverage collection |
Contribution Workflow
Branching
Always pull the latest
mainbefore creating a new branch:git checkout main git pull origin mainCreate your feature branch from
mainusing the naming convention:Branch Type Pattern Example Feature feature/<short-description>feature/add-retry-policyBug fix bugfix/<short-description>bugfix/connection-timeoutChore chore/<short-description>chore/update-dependenciesRelease release/v<version>release/v3.1.0Docs docsfixordocs/<description>docs/update-readmegit checkout -b feature/my-feature-name
Commit Messages
Write clear, descriptive commit messages. Follow these conventions:
- Use imperative mood or a concise description of the change
- Reference the PR number when applicable (GitHub adds this on squash-merge)
- Keep the subject line under 72 characters
Examples of good commit messages:
Add retry policy for transient ingestion errors
Update Microsoft.Azure.Kusto.Ingest to ver. 14.1.0
Fix connection string visibility issue
ADXSinkE2ETest - increase timeout for flaky testsPull Request Titles
PR titles follow the same convention as commit messages — they should be clear and descriptive since PRs are squash-merged and the PR title becomes the commit message on main.
Examples of good PR titles:
Microsoft.Azure.Kusto.Ingest ver. 14.1.0
Support for AuthenticationType = AadWorkloadIdentity
Fix connection timeout on batch ingestion
Update test dependencies to latest stable versionsPull Request Guidelines
- Target the
mainbranch - Ensure CI passes (build + tests)
- Provide a clear description of the change and why it is needed
- Link related issues if applicable
CI/CD
Build & Test (dotnet.yml)
- Triggers: Push to
main, PRs targetingmain - Runs on:
ubuntu-latest - Timeout: 15 minutes
- Steps: Restore → Build (Release) → Test (with ADX E2E environment)
- Environment:
e2e(providesCONNECTION_STRINGandDATABASEvars)
NuGet Publish (nuget.yml)
- Trigger: Manual (
workflow_dispatch) - Steps: Restore → Build → Pack → Push to NuGet.org
- Secret:
NUGET_API_KEY
Architecture Notes
Core Pattern
ADXTarget extends NLog's AsyncTaskTarget, which provides:
- Async batching of log events
- Configurable batch size, queue limits, and overflow behavior
- Thread-safe lazy writer pattern
Ingestion Modes
The target supports two ingestion modes:
- Streaming ingestion — Low latency, logs sent immediately via
IKustoIngestClient - Queued ingestion — Higher throughput, logs batched and queued via
IKustoQueuedIngestClient
Authentication
Authentication is configured via AuthenticationType enum and KustoConnectionStringBuilder. Supported modes:
- Connection string (default)
- AAD User Managed Identity
- AAD System Managed Identity
- AAD Workload Identity (Kubernetes)
- Azure CLI
- User Prompt (dev only)
Data Flow
LogEvent → ADXLogEvent (JSON) → GZip compress → MemoryStream → Kusto Ingest Client → ADX TableKey implementation details:
- Uses
RecyclableMemoryStreamManagerfor efficient memory management - JSON serialization with custom
UnsafeRawJsonConverterfor properties - Automatic retry with skip for authentication and permanent errors
- Connection string translation between engine and ingest endpoints
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

