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
- A Microsoft account or a Microsoft Entra user identity. An Azure subscription isn't required.
- An Azure Data Explorer cluster and database. Create a cluster and database.
- Sign in to the Azure Data Explorer web UI and add a connection to your cluster.
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:
Select Query in the left pane.
Right-click on the desired table, and select Generate > Sample code.
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:
- Ingest into an existing table
- Ingest into a new table
- Ingest data from:
- Blob Storage
- A local file
Destination
In the Destination tab:
Select the Cluster and Database.
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.
Select the Programming language for your app.
Select Next: Source.
Source
In the Source tab:
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.
If you selected Query and ingest, select the source file or blob for ingestion.
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:
Confirm the autogenerated Compression type.
Choose the Data format from the formats supported by Azure Data Explorer for ingestion. Different formats have different specifications.
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.
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.