Use the sample app generator wizard to create code to ingest and query your data

The sample app generator wizard is a tool that allows you to create a working app to ingest and query your data in your preferred programming language. The generated code references the relevant SDK frameworks and is tailored to your cluster and data. The app is a self-contained, executable example that demonstrates how to connect to a cluster using authentication, administer, and ingest and query data using the SDK.

You can use the generated code as a baseline to write your own apps, altering the code as you go, or you can copy sections of code into your own apps. The code includes comments with tips, best practices, links to reference material, and recommended TODO changes when adapting the code to your needs.

Prerequisites

Note

To enable access between a cluster and a storage account without public access (restricted to private endpoint/service endpoint), see Create a Managed Private Endpoint.

Access the wizard

The sample app generator wizard guides you through the ingestion process.

To access the wizard from the Azure Data Explorer web UI:

  1. Select Query in the left pane.

  2. Right-click on the desired table, and select Generate > Sample code.

    Screenshot showing Sample app generator card from table context menu.

Generate a sample app

This section describes the wizard in general. The options you select depend on what data format you're ingesting, what kind of data source you're ingesting from, and whether you're ingesting into a new or existing table.

The wizard guides you through the following options:

Destination

In the Destination tab:

  1. Select the Cluster and Database.

  2. Choose whether to use an Existing table or a New table. For an existing table, select the table from the options. For a new table, give the table a name.

  3. Select the Programming language for your app.

    Screenshot of Azure Data Explorer web UI showing the Sample app generator destination tab.

  4. Select Next: Source.

Source

In the Source tab:

  1. Choose from the following options:

    • Query and ingest: Upload data for ingestion and receive the corresponding code for both ingestion and querying of the specified data.
    • Query only: Get the code to query the table selected in the previous tab.
  2. If you selected Query and ingest, select the source file or blob for ingestion.

  3. Select Next: Schema.

Schema

In the Schema tab, the service automatically generates schema and ingestion properties, which you can modify as needed. To set up the schema:

  1. Confirm the autogenerated Compression type.

  2. Choose the Data format from the formats supported by Azure Data Explorer for ingestion. Different formats have different specifications.

  3. In the Partial data preview window, adjust the schema as needed. To do this, select the arrow at the top of a column to open a menu with options for changing the data type, creating a new column, deleting a column, and more. If your data is in Parquet, JSON, or Avro format, you can apply mapping transformations.

    Screenshot of how to open the schema adjustment options.

  4. Select Next: Generate sample app.

Tip

To view, edit, and copy the commands generated from your inputs, open the command viewer above the Partial data preview window.

Mapping transformations

Parquet, JSON, and Avro data formats support simple ingest-time transformations. To apply mapping transformations, create or update a column in the Partial data preview window.

Mapping transformations can be performed on a column of type string or datetime, with the source data having data type int or long. Supported mapping transformations are:

  • DateTimeFromUnixSeconds
  • DateTimeFromUnixMilliseconds
  • DateTimeFromUnixMicroseconds
  • DateTimeFromUnixNanoseconds

For more information, see Mapping transformations.

Generate

Once you've completed schema mapping and column manipulations, the sample app generator wizard starts the code generation process. After code generation, the sample app project will be available for download as a ZIP file.

Detailed instructions for running the project with the selected SDK are provided upon successful generation and within the sample project file. In addition, the wizard gives you options to use Quick queries for initial exploration of your data.

Note

You may need to run the downloaded app for the Quick queries to work.