0

Our data is stored in the Blob storage and we are using Azure Synape Analytics to query the data. This works fine with the Azure UI Interface. We are trying to do this programtically via REST APIs. Found this link which discuss on the REST support: https://learn.microsoft.com/en-us/rest/api/synapse/data-plane/sql-script, but could not find a REST / SDK support to execute these SQL queries.

I'm new to using Azure Synapse and azure service, so any advice you can provide is much appreciated.

https://learn.microsoft.com/en-us/rest/api/synapse/data-plane/sql-script

  • you can use SQL pools in synapse studio to execute SQL queries or SQL scripts. – Bhavani Jan 13 '23 at 09:22
  • @Bhavani Is there any java sdk or REST support to execute these SQL queries – SNEHAL DANGE Jan 13 '23 at 14:29
  • I didn't get your question; do you want to connect with rest API to execute SQL scripts in synapse or do you want any tool to execute SQL scripts in synapse? Could you please give the clarification? – Bhavani Jan 16 '23 at 07:32

1 Answers1

0

This is related to fetch the conten from rest API nor for executing the scripts, for that we need to run script activity in pipeline. If we want to run SQL scripts in Synapse analytics, we are having options of SQL pools without using pipelines. we can import the script which we want to execute at develop in synapse analytics. Image for reference:

enter image description here

If we want to create new script, we can create by using new SQL script option which is in above picture.

If we want to retrieve the data from blob storage, we can create eternal tables in dedicated SQL pool or serverless pool. serverless pool is built in synapse analytics. We can create dedicated SQL pool at Manage->SQL pools. Image for reference:

enter image description here

we need to create external table to retrieve data from blob storage, for that we need to create external data source and external file system. External data source: enter image description here

Script related to external data source created automatically with script.

CREATE  EXTERNAL  DATA  SOURCE [ExternalDataSource] WITH

(

LOCATION = 'https://<STORAGEACCOUNT>.blob.core.windows.net/<CONTAINER>'

)

Image for reference:

enter image description here

After that we need to create external file format using below procedure:

enter image description here

Here also script regarding file format created atomatically.

CREATE  EXTERNAL  FILE  FORMAT [ExternalFileFormat] WITH

(

FORMAT_TYPE = DELIMITEDTEXT

)

Image for reference:

enter image description here

we need to create external table by using above data source and file format.

enter image description here

script created automatically need to enter values in the script:

CREATE  EXTERNAL  TABLE [dbo].[ExternalTable]

(

[Id] INT

)

WITH

(

LOCATION = '/folder/file',

DATA_SOURCE = [DataSource1],

FILE_FORMAT = [FileFormat1]

)

In this you can access data from blob storage using synapse sql pools without using synapse pipelines and you can query those table.

Bhavani
  • 1,725
  • 1
  • 3
  • 6