Synapse Apache Spark connector Azure SQL error

Pavankumar-3526 306 Reputation points
2023-05-23T01:57:56.83+00:00

Hello,

I am following the document to query the SQL table using the service principal.

https://learn.microsoft.com/en-us/sql/connect/spark/connector?view=sql-server-ver16

context = adal.AuthenticationContext(authority)
token = context.acquire_token_with_client_credentials(resource_app_id_url, service_principal_id, service_principal_secret)
access_token = token["accessToken"]

jdbc_db = spark.read \
        .format("com.microsoft.sqlserver.jdbc.spark") \
        .option("url", url) \
        .option("dbtable", table_name) \
        .option("accessToken", access_token) \
        .option("encrypt", "true") \
        .option("hostNameInCertificate", "*.database.windows.net") \
        .load()



getting the below error. any advise?

token = context.acquire_token_with_client_credentials("https://database.windows.net/", service_principal_id, service_principal_secret)
     16 access_token = token["accessToken"]

~/cluster-env/env/lib/python3.8/site-packages/adal/authentication_context.py in __init__(self, authority, validate_authority, cache, api_version, timeout, enable_pii, verify_ssl, proxies)
     86             for details.
     87         '''
---> 88         self.authority = Authority(authority, validate_authority is None or validate_authority)
     89         self._oauth2client = None
     90         self.correlation_id = None

~/cluster-env/env/lib/python3.8/site-packages/adal/authority.py in __init__(self, authority_url, validate_authority)
     52         self._host = None
     53         self._tenant = None
---> 54         self._parse_authority()
     55 
     56         self._authorization_endpoint = None

~/cluster-env/env/lib/python3.8/site-packages/adal/authority.py in _parse_authority(self)
     94             self._tenant = path_parts[1]
     95         except IndexError:
---> 96             raise ValueError("Could not determine tenant.")
     97 
     98     def _perform_static_instance_discovery(self):

ValueError: Could not determine tenant.
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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    2 deleted comments

    Comments have been turned off. Learn more

Your answer

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