in packages/quick_start/src/SampleApp.ts [335:368]
private static async ingestData(
dataFile: ConfigData,
dataFormat: DataFormat,
ingestClient: IngestClient,
databaseName: string,
tableName: string,
mappingName: string,
ignoreFirstRecord: boolean,
) {
const sourceType = dataFile.sourceType.toLowerCase();
const sourceUri = dataFile.dataSourceUri;
mappingName = mappingName ? mappingName : "DefaultQuickstartMapping" + uuidv4().substring(0, 4);
await this.waitForUserToProceed(`Ingest '${sourceUri}' from '${sourceType}'`);
// Tip: When ingesting json files, if each line represents a single-line json, use MULTIJSON format even if the file only contains one line.
// If the json contains whitespace formatting, use SINGLEJSON. In this case, only one data row json object is allowed per file.
// Note: No need to add "nosource" option as in that case the "ingestData" flag will be set to false, and it will be impossible to reach this code
// segment.
dataFormat = dataFormat === DataFormat.JSON ? DataFormat.MULTIJSON : dataFormat;
// Tip: Kusto's Node SDK can ingest data from files, blobs and open streams.See the SDK's samples and the E2E tests in azure.kusto.ingest for
// additional references.
switch (sourceType) {
case SourceType.LocalFileSource:
await Ingestion.ingestFromFile(ingestClient, databaseName, tableName, sourceUri, dataFormat, mappingName, ignoreFirstRecord);
break;
case SourceType.BlobSource:
await Ingestion.ingestFromBlob(ingestClient, databaseName, tableName, sourceUri, dataFormat, mappingName, ignoreFirstRecord);
break;
default:
Utils.errorHandler(`Unknown source '${sourceType}' for file '${sourceUri}'`);
break;
}
}