Skip to content

hfleitas/SignalRToKusto

Repository files navigation

🚦 SignalR to Kusto 🤿

Dotnet Azure Function that streams messages from a SignalR websocket server to Kusto (Azure Data Explorer/Synapse DX Pool/Fabric KQL Database) in realtime using Kusto SDK bindings.

Usage 💻

  • RTI Saturday Presentation: 1000s of Trucks a Day in Microsoft Fabric
  • Azurite extension in VSCode is required for runing the function locally, if local setting AzureWebJobsStorage is set to UseDevelopmentStorage=true. Open command pallet and choose > Azurite: Start.
  • If Azurerite fails to start the Blob service local emulator, then set AzureWebJobsStorage to use an actual Azure Storage Account access key connection string. ie. DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<Key>;EndpointSuffix=core.windows.net

Create a local file local.settings.json with your setting values.

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true", 
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "AzureWebJobsSecretStorageType": "files",
        "AzureWebJobsDashboard": "",
        "KustoConnectionString": "Data Source=https://<kustocluster>.<region>.kusto.windows.net;Database=e2e;Fed=True;AppClientId=<AppId>;AppKey=<AppKey>;Authority Id=<Tenant Id>",
        "SignalRConnection": "https://<websocket-client-url>/register?apikey=<APIKey>",
        "MethodName":"<SignalRMethodName>",
        "KustoDB": "<DatabaseName>",
        "KustoTable": "<TableName>"
    }
}

To install dependencies 📦:

  • Before you run the function locally install these exact versions.
  • Use the VSCode extenstion NuGet package manager to add them. It will automatically include them as Package References in your project file. ie. SignalRToKusto.csproj.
  • Run VSCode terminal commands:
dotnet add package Microsoft.AspNetCore.SignalR.Client --version 6.0.2
dotnet add package Microsoft.Azure.WebJobs.Extensions.Kusto --version 1.0.9-Preview
dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage --version 5.2.2
dotnet add package Microsoft.NET.Sdk.Functions --version 4.3.0

To run the function locally 👟:

func start --csharp --port 7104 --verbose

To deploy the function 🚀:

  • Can deploy to an existing function & app service plan, or create a new function prior.
  • Setup the enviroment variables similarly to your local.settings.json using an azure storage account access key connection string.
winget install -e --id Microsoft.AzureCLI
Az Login
Connect-AzAccount -TenantId <your-tenatnt-id>
Set-AzContext -SubscriptionName <your-subcription-name>
func azure functionapp publish <your-az-function-name> -subscription <your-subcription-name>

To monitor for duplicates 🔎:

MyRawTable
| where ingestion_time() between(datetime('2024-03-15T14:32:05.5207657Z') .. datetime('2024-03-15T15:32:05.5207657Z')) //1hr
| project tostring(message)
| summarize count() by message
| where count_ > 1
| count

Refrences 📑

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages