Is there any way to execute the SQL query via Rest Endpoints in Azure Synapse Analystics

snehal dange 0 Reputation points
2023-01-13T09:45:34.5866667+00:00

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 programmatically 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

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
2,625 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
1,406 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 19,116 Reputation points Microsoft Employee
    2023-01-16T08:54:14.5366667+00:00

    Hi snehal dange ,

    Welcome to Microsoft Q&A platform and thanks for posting your question here.

    As I understand your query here, you are trying to run SQL queries via REST API or via SDK using Azure synapse analytics. Please let me know if that is not the ask here.

    • You can store your SQL queries inside SQL scripts option in Develop tab and execute it directly in the Synapse workspace. Click here to know more about it.
    • REST APIs mentioned here are to fetch the content of the SQL scripts, to create and update those scripts etc. , not to execute the scripts. In order to execute those scripts, you can pass on the result obtained to 'Script activity' or run a stored procedure in Synapse pipeline. Check out this thread for more details on how to do the same.
    • You can use a serverless SQL pool to query data files in various common file formats, like CSV, JSON and parquet by using the following syntax:
    SELECT TOP 100 *
    FROM OPENROWSET(
        BULK 'https://mydatalake.blob.core.windows.net/data/files/*.csv',
        FORMAT = 'csv') AS rows
    

    For more details around the same , check this blog post: Query files using a serverless SQL pool

    Note: Synapse also supports Python and JAVA SDK .


    Hope it helps. Please do consider clicking Accept Answer and Up-Vote for the same as accepted answers help community as well

    No comments