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:
- 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.
- 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.