In my previous blog post KQL Series – ingesting data using Azure Stream Analytics I talked about one of the more easier ways to ingest data – which is via csv.
Here is how you can:
- Create a table in Azure Data Explorer: You can use the Azure Data Explorer Web UI, Azure CLI, or Azure PowerShell to create a table. The table should have the same structure as the CSV file you want to ingest.
- Upload the CSV file to Azure Blob Storage: You can use the Azure portal or Azure Storage Explorer to upload the CSV file to Azure Blob Storage.
- Create a data connection in Azure Data Explorer: You can use the Azure Data Explorer Web UI or Azure PowerShell to create a data connection to the Azure Blob Storage container where the CSV file is located.
- Define an ingestion mapping: You can use the Azure Data Explorer Web UI or Azure PowerShell to define an ingestion mapping that maps the columns in the CSV file to the columns in the Azure Data Explorer table.
- Ingest the data: You can use the Azure Data Explorer Web UI or Azure PowerShell to start the ingestion process. The ingestion process will read the CSV file from Azure Blob Storage, apply the ingestion mapping, and write the data to the Azure Data Explorer table.
Below is an example PowerShell script that ingests data from a CSV file into Azure Data Explorer:
$clusterUrl = “https://..kusto.windows.net”
$databaseName = “”
$tableName = “”
$csvPath = “https://.blob.core.windows.net//.csv”
$mapping = @’
[
{
“column”: “Timestamp”,
“datatype”: “datetime”,
“format”: “yyyy-MM-dd HH:mm:ss”
},
{
“column”: “Value”,
“datatype”: “real”
}
]
‘@
Connect-AzKusto -Cluster $clusterUrl -Database $databaseName
New-AzKustoTableMapping -TableName $tableName -MappingJson $mapping
Start-AzKustoIngestion -TableName $tableName -MappingName $tableName -DataFormat Csv -DataCsvUrl $csvPath
Replace <clustername>
, <region>
, <databasename>
, <tablename>
, <storageaccountname>
, <containername>
, and <filename>
with your own values.
Pretty easy right?
Find more details here:
https://learn.microsoft.com/bs-latn-ba/azure/data-explorer/ingest-sample-data?tabs=ingestion-wizard
#Yip.