How can I access the Synapse REST API from Spark notebooks in a Synapse workspace deployed with a private endpoint?

Kartik Rana 21 Reputation points
2025-04-24T06:02:59.9733333+00:00

I'm trying to access the Synapse REST API from Spark notebooks in my Synapse workspace, which is deployed with a private endpoint and has public network access disabled. When I attempt to call the API from within a notebook, I get the following error:

PublicNetworkAccessDenied

However, if I run the same code locally while connected to our corporate VPN, it works without any issues.

Just to clarify, the private endpoint setup generally works as expected. For example:

I need to be connected to the VPN to even load items in the Synapse Studio.

Data exports from the serverless SQL pool to Power BI also work seamlessly through the private endpoint.

So, the private networking seems correctly configured and is functioning well for most services.

The issue arises only when trying to access the Synapse REST API from Spark notebooks.

How can I configure my environment to allow REST API calls from within Spark notebooks to route through the private endpoint as well?

Note: I need a solution where I don't have to use the Web activity in a pipeline

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.
5,318 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ganesh Gurram 6,460 Reputation points Microsoft External Staff
    2025-04-25T11:06:01.36+00:00

    @Kartik Rana

    According to this MS documentation: https://learn.microsoft.com/en-us/azure/synapse-analytics/security/connectivity-settings?tabs=workspace

    "When Public network access is set to Disable, only connections from private endpoints are allowed. All connections from public endpoints will be denied with an error message similar to: PublicNetworkAccessDenied."

    Based on your setup and the error message you're receiving, the behavior you're experiencing is expected and is documented in Azure Synapse Analytics connectivity settings.

    When public network access is disabled on your Synapse workspace, only private endpoint traffic is allowed, and any requests made to public endpoints (including from Spark notebooks within the same workspace) are denied. This is why your REST API call from inside the Spark notebook fails with the PublicNetworkAccessDenied error.

    Although the Spark notebook is running within the Synapse workspace, REST API calls to *.dev.azuresynapse.net (which is part of the control plane) are still routed through the public endpoint. Since public access is disabled, these calls are blocked.

    Recommended approach:

    1. Web Activity in Synapse Pipelines (preferred method) - Although you prefer not to use this, it's worth mentioning that this is the recommended and supported method for invoking REST APIs from within Synapse in a secure and private way.
    2. Azure Function or Logic App (in same VNet) - Deploy a small Azure Function or Logic App within your private network. It can securely call the Synapse REST API using a managed identity and be triggered from your notebook or other services.

    Unfortunately, calling the Synapse REST API directly from Spark notebooks in a workspace with public network access disabled is currently not supported due to these network routing restrictions.

    For more details refer: https://learn.microsoft.com/en-us/azure/synapse-analytics/security/connectivity-settings?tabs=workspace

    I hope this information helps.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues. 

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.