Forum Discussion
Write data into synapse dedicated sql pool from fabric notebook
Yes, it is possible to write data from a Microsoft Fabric Notebook Spark DataFrame into an Azure Synapse Dedicated SQL Pool.
The recommended approach is to use the Synapse Spark connector for SQL DW, which allows Spark to write data directly into Synapse Dedicated SQL Pool.
Example:
# Install the connector if required
# (Usually available in Fabric Spark runtime)
df.write \
.format("com.databricks.spark.sqldw") \
.option("url", "jdbc:sqlserver://<server-name>.sql.azuresynapse.net:1433;database=<database-name>") \
.option("dbTable", "<schema>.<table_name>") \
.option("forwardSparkAzureStorageCredentials", "true") \
.option("tempDir", "abfss://<container>@<storage-account>.dfs.core.windows.net/<temp-folder>") \
.mode("overwrite") \
.save()Before running this, make sure:
The Fabric workspace identity or user identity has permission to access the Synapse SQL Pool.
The required network connectivity is available (firewall, private endpoints, managed identity configuration if applicable).
The staging storage location (tempDir) is accessible because the connector uses Azure Storage as an intermediate step before loading into Dedicated SQL Pool.
The target table permissions are configured correctly (CREATE TABLE, INSERT, etc., depending on the operation).
Another option is to use the standard JDBC approach:
df.write \
.format("jdbc") \
.option("url", "jdbc:sqlserver://<server-name>.sql.azuresynapse.net:1433;database=<database-name>") \
.option("dbtable", "<schema>.<table_name>") \
.option("user", "<username>") \
.option("password", "<password>") \
.mode("append") \
.save()However, for larger datasets, the dedicated SQL Pool connector is generally preferred because it uses parallel loading.
A few best practices:
For large data volumes, avoid row-by-row inserts through JDBC.
Use bulk loading patterns whenever possible.
Partition your Spark DataFrame appropriately before writing.
Monitor Synapse SQL Pool distribution and table design (hash distribution, round-robin, clustered columnstore indexes) for better performance.
For more information:
Azure Synapse Dedicated SQL Pool Spark connector: https://learn.microsoft.com/azure/synapse-analytics/spark/synapse-spark-sql-pool-import-export
Fabric Spark notebooks: https://learn.microsoft.com/fabric/data-engineering/how-to-use-notebook