Hello @Mritunjay Daiya welcome to QnA Forum.
I hope the Managed Identity is enabled on the Synapse Workspace/
Managed identity for Azure Synapse
Is the IMDS is accessible from your Synapse Notebook, Such as,
!curl -H Metadata:true "http://169.254.169.254/metadata/instance?api-version=2021-01-01"
This should return metadata about the instance, including the instance ID and SKU.
Any missing packages?
Did you see a similar thread on StackOverflow? Let me know if that helps?
- Create an Azure SQl DB user with required roles and permissions.
- Create new linked service to the Azure SQL DB using the system assigned managed identity.
XMLAI ConvertCopy
server = 'dbservere.database.windows.net'
Port = 1433
Database = "db"
jdbcUrl = f"jdbc:sqlserver://{server}:{Port};databaseName={Database};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30"
token=TokenLibrary.getConnectionString("AzureSqlDatabase1")
query = "(SELECT * FROM students)as tb"
conn_Prop = {
"driver" : "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"accessToken" : token
}
df = spark.read.jdbc(url=jdbcUrl, table=query, properties=conn_Prop)
display(df)