0

When i query my delta table from synpase studio, i can see the data all good.

But when i am connecting trough data studio via sql login (or databricks), It seems that i can not query it :

CREATE or alter view stock
as SELECT * 
FROM
    OPENROWSET(
        BULK 'https://tesdvsrc18732.dfs.core.windows.net/adlse-fr/be_stock/',
        FORMAT = 'DELTA'
    ) AS [result]

Started executing query at Line 1 Msg 15151, Level 16, State 1, Line 1 Cannot find the CREDENTIAL 'https://tesdvsrc18732.dfs.core.windows.net/adlse-fr/be_stock/', because it does not exist or you do not have permission. Total execution time: 00:00:00.025

I cannot as well see the view in the UI : enter image description here

I can see it however if connecting via Azure Active Directory.

Any suggestion, observation or expertise would be much appreciated. I get the same error message from azure databricks

OrganicMustard
  • 1,158
  • 1
  • 15
  • 36

1 Answers1

0

I found a way to do what i wanted. So i'm posting it here.

On synapse

CREATE MASTER KEY

CREATE DATABASE SCOPED CREDENTIAL [SasToken_MyStorage]
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = '?sv=2020-08-04&ss=bfq****************************************************************************************************************************************************PA%3D';
GO
CREATE EXTERNAL DATA SOURCE [MyDataSource]
WITH ( LOCATION = 'https://tesdvsrc18732.dfs.core.windows.net',
CREDENTIAL = [SasToken_MyStorage]
)

I think this one is also needed but not sure :

GRANT CONTROL ON DATABASE SCOPED CREDENTIAL :: [SasToken_MyStorage] TO userDatabricks

On databricks/data studio

query = """
CREATE or alter view dbo.stock
as SELECT * 
FROM
    OPENROWSET(
        BULK '/adlse-fr/be_stock/',
        FORMAT = 'DELTA',
        DATA_SOURCE = 'MyDataSource'
    ) AS [result]
"""

stmt = sql_con.createStatement()
stmt.executeUpdate(query)
stmt.close()
OrganicMustard
  • 1,158
  • 1
  • 15
  • 36
  • 1
    Glad to know that your issue has resolved. After 48 hours, you can accept it as answer( click on the check mark beside the answer to toggle it from greyed out to filled in). This can be beneficial to other community members. Thank you. – CHEEKATLAPRADEEP Dec 06 '21 at 05:13