Atvik
Mar 31, 11 PM - Apr 2, 11 PM
Stærsti Fabric, Power BI og SQL námsviðburðurinn. 31. mars – 2. apríl. Notaðu kóðann FABINSIDER til að spara $400.
Skráðu þig í dagÞessi vafri er ekki lengur studdur.
Uppfærðu í Microsoft Edge til að nýta þér nýjustu eiginleika, öryggisuppfærslur og tæknilega aðstoð.
Notebooks are both readable documents containing data analysis descriptions and results and executable documents that can be run to perform data analysis. In this article, you learn how to use a Fabric notebook to connect to data in a KQL Database and run queries using native KQL (Kusto Query Language). For more information on notebooks, see How to use Microsoft Fabric notebooks.
There are two ways to use Fabric notebooks with data from your KQL database:
Fabric notebooks provide code snippets that help you easily write commonly used code patterns. You can use snippets to write or read data in a KQL database using KQL.
Navigate to an existing notebook or create a new one.
In a code cell, begin typing kusto.
Select the snippet that corresponds to the operation you want to perform: Write data to a KQL database or Read data from a KQL database.
The following code snippet shows the example data read operation:
# Example of query for reading data from Kusto. Replace T with your <tablename>.
kustoQuery = "['T'] | take 10"
# The query URI for reading the data e.g. https://<>.kusto.data.microsoft.com.
kustoUri = "https://<yourKQLdatabaseURI>.z0.kusto.data.microsoft.com"
# The database with data to be read.
database = "DocsDatabase"
# The access credentials.
accessToken = mssparkutils.credentials.getToken('kusto')
kustoDf = spark.read\
.format("com.microsoft.kusto.spark.synapse.datasource")\
.option("accessToken", accessToken)\
.option("kustoCluster", kustoUri)\
.option("kustoDatabase", database)\
.option("kustoQuery", kustoQuery).load()
# Example that uses the result data frame.
kustoDf.show()
The following code snippet shows the example write data operation:
# The Kusto cluster uri to write the data. The query Uri is of the form https://<>.kusto.data.microsoft.com
kustoUri = ""
# The database to write the data
database = ""
# The table to write the data
table = ""
# The access credentials for the write
accessToken = mssparkutils.credentials.getToken('kusto')
# Generate a range of 5 rows with Id's 5 to 9
data = spark.range(5,10)
# Write data to a Kusto table
data.write.\
format("com.microsoft.kusto.spark.synapse.datasource").\
option("kustoCluster",kustoUri).\
option("kustoDatabase",database).\
option("kustoTable", table).\
option("accessToken", accessToken ).\
option("tableCreateOptions", "CreateIfNotExist").mode("Append").save()
Enter the required information within the quotation marks of each field in the data cell:
Field | Description | Related links |
---|---|---|
kustoQuery | The KQL query to be evaluated. | KQL overview |
KustoUri | The query URI of your KQL database. | Copy a KQL database URI |
database | The name of your KQL database. | Access an existing KQL database |
data | The data to be written to the table. |
Run the code cell.
When you create a notebook as a related item in a KQL database, the notebook is given the same name as the KQL database and is prepopulated with connection information.
Browse to your KQL database.
Select New related item > Notebook.
A notebook is created with the KustoUri and database details prepopulated.
Enter the KQL query to be evaluated in the kustoQuery field.
Run the code cell.
Atvik
Mar 31, 11 PM - Apr 2, 11 PM
Stærsti Fabric, Power BI og SQL námsviðburðurinn. 31. mars – 2. apríl. Notaðu kóðann FABINSIDER til að spara $400.
Skráðu þig í dagÞjálfun
Eining
Work with real-time data in a Microsoft Fabric eventhouse - Training
Microsoft Fabric provides a scalable and flexible store for real-time data.
Vottorð
Microsoft Certified: Fabric Data Engineer Associate - Certifications
As a Fabric Data Engineer, you should have subject matter expertise with data loading patterns, data architectures, and orchestration processes.
Skjöl
Tutorial- Use a notebook with Apache Spark to query a KQL database - Microsoft Fabric
Learn how to import and query the NYC GreenTaxi notebook in your Real-Time Intelligence in Microsoft Fabric environment using Apache Spark.
Create a KQL database - Microsoft Fabric
Learn how to create a KQL database in Real-Time Intelligence.
Access the data profile of a table in Real-Time Intelligence - Microsoft Fabric
Learn how to access the data profile of a table in Real-Time Intelligence.