in quick_start/sample_app.py [0:0]
def main():
print("Kusto sample app is starting...")
app = KustoSampleApp()
app.load_configs(app.CONFIG_FILE_NAME)
if app.config.authentication_mode == "UserPrompt":
app.wait_for_user_to_proceed("You will be prompted *twice* for credentials during this script. Please return to the console after authenticating.")
kusto_connection_string = Utils.Authentication.generate_connection_string(app.config.kusto_uri, app.config.authentication_mode)
ingest_connection_string = Utils.Authentication.generate_connection_string(app.config.ingest_uri, app.config.authentication_mode)
# Tip: Avoid creating a new Kusto/ingest client for each use.Instead, create the clients once and reuse them.
if not kusto_connection_string or not ingest_connection_string:
Utils.error_handler("Connection String error. Please validate your configuration file.")
else:
# Make sure to use context manager for the Kusto client, as it will close the underlying resources properly.
# Alternatively, you can use the client as a regular Python object and call close() on it.
with KustoClient(kusto_connection_string) as kusto_client:
with QueuedIngestClient(ingest_connection_string) as ingest_client:
app.pre_ingestion_querying(app.config, kusto_client)
if app.config.ingest_data:
app.ingestion(app.config, kusto_client, ingest_client)
if app.config.query_data:
app.post_ingestion_querying(kusto_client, app.config.database_name, app.config.table_name, app.config.ingest_data)
print("\nKusto sample app done")