Jump to content

Featured Replies

Posted

Introduction

 

 

Microsoft Fabric is a powerful unified analytics solution that allows users to seamlessly connect to various data sources, including Azure Databricks, and create insightful reports and visualizations without the need to move the data.

 

 

 

In this tutorial, we'll show you step-by-step how to connect to Azure Databricks generated Delta Tables and create a report in Microsoft Fabric.

 

By the end of this tutorial, you'll have the knowledge needed to read Azure Databricks generated Delta Tables from a Microsoft Fabric using Notebook and SQL query. You will also learn how to create a Power BI report that can help drive business decisions. So, let's get started!

 

 

 

777x370vv2.png.a8dd4e000b773737f49255b68d68d2a5.png

 

 

 

Prerequisites

 

 

Before you connect, complete these steps:

 

  • An Azure Databricks workspace
  • An ADLS Gen2 account to store delta table and a parquet file
  • A Fabric workspace. For more information, see Fabric trial docs.
  • A lakehouse in Fabric workspace. For more information, see Create a lakehouse with OneLake.

 

Create Delta Table in Databricks

 

  1. Create a delta table from Databricks Notebook.

 

In this case, I am using parquet files stored in ADLS Gen2 account to create a delta table.

 

 

 

%SQL

 

--create external table from parquet files stored in ADLS Gen2

CREATE TABLE fact_internet_sales

LOCATION 'abfss://demo@[yourdatalake].dfs.core.windows.net/fact_internet_sales'

AS

SELECT * FROM PARQUET.`abfss://data@[yourdatalake].dfs.core.windows.net/fact_internet_sales`;

 

 

 

564x173vv2.png.5a544ade3d8017134be2fbcbc05e5a4c.png

 

 

 

 

 

%Python

 

#Read parquet files stored in ADLS Gen2

df = spark.read.format('parquet')\

.load("abfss://data@[yourdatalake].dfs.core.windows.net/fact_internet_sales")

 

#Write to an external delta table

df.write \

.format("delta") \

.option("path", "abfss://demo@[yourdatalake].dfs.core.windows.net/fact_internet_sales") \

.saveAsTable("fact_internet_sales")

 

 

 

557x199vv2.png.a52306e3c70471da25dac3b470bd188d.png

 

 

 

 

Read the Delta Table in Fabric

 

 

Open the Fabric workspace to read, analyse and visualise the data.

 

 

Create shortcut to delta table

 

 

 

 

  1. In the lakehouse, click on ellipses (…) next to the Tables and select New Shortcut.
    mediumvv2px400.png.3d00f067c9962ca6a8518d8c77fa6f21.png
     
     
     
     
  2. In the New shortcut wizard, select Azure Data Lake Storage Gen2 tile. For more information, see Create an Azure Data Lake Storage Gen2 shortcut 711x299vv2.png.02f8f53fd4237ec001d03ec43e706db5.png
     
     
     
  3. Enter the storage account URL in Connection settings.

    Field

    Details

    URL

    https://StorageAccountName.dfs.core.windows.net

     
    703x390vv2.png.be4041b03854f01ccfcb6c3fcf3856a8.png
     
     
  4. Enter the connection details (sign in if required) and select Next.
    In this case, I am using ‘Organization Account’ Authentication kind and hence need to sign in.
     

    Field

    Details

    Connection

    Existing connections for the specified storage location will appear in the drop-down. If none exist, create a new connection.

    Connection name

    The Azure Data Lake Storage Gen2 connection name.

    Authentication kind

    The supported models are: Organizational account, Account Key, Shared Access Signature (SAS), and Service principal. For more information, see ADLS shortcuts.

     
    721x400vv2.png.c227ba65dce51022ce85711ed21e4441.png
     
     
  5. Enter the Shortcut Name and Sub path details and then click Create.

    Field

    Details

    Shortcut Name

    Name of your shortcut

    URL

    The Azure Data Lake Storage Gen2 URL from the last page.

    Sub Path

    The directory where the delta table resides.

     
    721x403vv2.png.b31e84e50555804b9f2bf5ac2544d659.png
     
     
  6. The shortcut pointing to the delta table (fact_internet_sales) created in the last section will now appear as a delta table under Tables in the Explorer pane.

  7. Click on the table (fact_internet_sales) and the data in the table will show up.
     
     
    717x433vv2.png.c1092e0f21390497b91f4908d1d88a15.png
     
     

 

 

 

Read the data from Notebook - Lakehouse mode

 

 

The data in the table can now be queried directly from the notebook in Fabric.

 

 

 

  1. Right-click on the table or click on ellipses (…) next to the table, click Open in notebook and then New notebook.
     
     
     
     
    437x334vv2.png.85bd3c82e8e7e4e888277aa7c168c815.png
     
     
     
     
     
  2. New notebook will appear with the query automatically generated to read the data in the table.

 

Select the
Run Cell
button or press
Ctrl+Enter
to execute the query and view the data.

 

664x402vv2.png.ff46d2d6b16ad15ddc45d0c5efd4e53f.png

 

 

 

 

 

Read the data using SQL - SQL Endpoint mode

 

 

The data in the table can also be queried directly using T-SQL query in Fabric.

 

 

 

  1. Browse to the SQL Endpoint created as part of Lakehouse provisioning from your workspace.

  2. After opening SQL Endpoint from the workspace, expand the database, schema and tables folder in the object Explorer to see all tables listed.
     
     

  3. Right-click on the table (fact_internet_sales) or click on ellipses (…) next to the table, click New SQL Query and then Select TOP 100 rows.
     
     
    359x272vv2.png.0d61d6159fb5ed482f8a46721ade96a3.png
     
     
     
  4. The script will be automatically generated and executed to show the data in the table or click on Run to execute the query.

 

620x376vv2.png.091e9a9aca4d6396c5ce74b9bd577054.png

 

 

 

 

 

Visualise the data in Fabric using Power BI

 

 

The data in delta table can now be accessed and analysed in Power BI. You can either create a new dataset or use the default dataset created as part of lakehouse provisioning for a new report. For more information, see Direct Lake in Power BI and Microsoft Fabric

 

 

Using new dataset

 

  1. If you are in the Lakehouse mode, click on New Power BI dataset.

 

mediumvv2px400.png.18fefc9b59c212b1e195a7e897e95e71.png

 

 

 

If you are in the SQL endpoint mode, click on
New Power BI dataset
from
Reporting
tab.

 

478x177vv2.png.61a3889d05b3581280151ff7c54f46d8.png

 

 

 

  1. In the New Dataset dialog, select the table to be included in the dataset and click Confirm.

 

322x407vv2.png.2017abe78102fc5f38b57eb10d95531f.png

 

 

 

  1. The dataset is automatically saved in the workspace, and then opens the dataset. In the web modelling experience page, click on New Report

 

567x336vv2.png.0601cc69c951e78fe2c5e2e26d4c80a2.png

 

 

 

  1. In the report authoring page, drag or select the attributes from Data pane to the left-hand side pane to be included in the visualization.

 

572x362vv2.png.9a2312001344ef18a37dd25fceeef89f.png

 

 

 

 

 

 

 

Using default dataset

 

  1. Select your workspace and open the default dataset.

 

855x306vv2.png.06e95954322d1b8180ca96615fd1b08f.png

 

 

 

  1. On the dataset page, click on Start from scratch to create a new report.

 

456x284vv2.png.728cd35ceb31eb8906bbc93632c4561f.png

 

 

 

  1. In the report authoring page, drag or select the attributes from Data pane to the left-hand side pane to be included in the visualization.

 

601x380vv2.png.35fa1ea88af21e967aca1aa22e6c4490.png

 

 

 

 

 

 

 

 

 

Summary

 

 

In conclusion, this guide provides a seamless solution for accessing Azure Databricks generated delta tables from Microsoft Fabric and visualizing the data in Power BI without the need to move the data. By following the steps outlined in this guide, you can easily connect to your delta tables and extract valuable insights from your data. With the power of Azure Databricks and Microsoft Fabric combined, you can take your data analysis to the next level and make informed decisions that drive business success.

 

 

 

Give it a try and let me know if this was helpful.

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...