functions/Publish-CsvToADXTable.ps1
function Publish-CsvToADXTable { <# .SYNOPSIS A PowerShell cmdlet to ingest CSV to Azure Data Explorer. .DESCRIPTION A PowerShell cmdlet to ingest CSV to Azure Data Explorer .EXAMPLE PS C:\> Publish-CsvToADXTable Explanation of what the example does .NOTES Author: Chendrayan Venkatesan #> [CmdletBinding()] param ( [System.String] $IngestUrl, [System.Guid] $ApplicationClientID, [system.String] $ApplicationClientKey, [System.Guid] $Authority, [System.String] $DatabaseName, [System.String] $TableName, [System.String] $FilePath ) $KustoConnectionStringBuilder = [Kusto.Data.KustoConnectionStringBuilder]::new($IngestUrl).WithAadApplicationKeyAuthentication( $ApplicationclientID, $ApplicationclientKey, $Authority ) $KustoClient = [Kusto.Ingest.KustoIngestFactory]::CreateQueuedIngestClient( $KustoConnectionStringBuilder ) $IngestionProperties = [Kusto.Ingest.KustoQueuedIngestionProperties]::new( $DatabaseName, $TableName ) $IngestionProperties.Format = [Kusto.Data.Common.DataSourceFormat]::csv $IngestionProperties.IgnoreFirstRecord = $true $IngestionResult = $KustoClient.IngestFromStorageAsync( $FilePath, $IngestionProperties ) $IngestionResult $IngestionResult.Result.GetIngestionStatusCollection() } |