Forum Discussion
Sql database in Fabric
- 1 year ago
Thank you for the response.
I followed all the suggested steps:
- Confirmed DNS and network connectivity (nslookup, Test-NetConnection).
- Verified I have ODBC Driver 18 and pyodbc installed.
- Ran my Python script with ActiveDirectoryInteractive and also tried other auth methods.
- Checked my Azure tenant and found I have no valid subscription assigned or active.
It turns out my subscription status is causing the issue. I don’t have any active Azure subscription in my tenant.
Hi, thanks for following up! I tried setting up a DSN as suggested, but unfortunately, I still couldn't connect to the server. I'm currently using Python for this project. If there are any specific samples or additional tips you could share for this language, that would be really helpful. Looking forward to your suggestions!
If the ODBC GUI is not working to set up a connection then you may have something else going on.
Some key things are:
- You need the whole server name but should omit any leading characters, like "tcp:". The ",1433" at the end is optional.
- You need the whole database name, GUID and all.
- Many drivers require the az cli to be installed https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli. Make sure to run an 'az login' after installing it.
Here's a basic python sample that will use the logged in users entra id:
"""
Connects to a SQL database using pyodbc
"""
import pyodbc
connectionString = f'Driver={{ODBC Driver 18 for SQL Server}};Server=<server>;Database=<database>;Encrypt=yes;TrustServerCertificate=no;Authentication=ActiveDirectoryInteractive'
conn = pyodbc.connect(connectionString)
SQL_QUERY = """
select Opportunity_Number, ProductID, Opportunity_Created_On, Quantity, Comments from Opportunity where Opportunity_number = 'OPP-500'
"""
cursor = conn.cursor()
cursor.execute(SQL_QUERY)
records = cursor.fetchall()
for r in records:
print(f"{r.Opportunity_Number}\t{r.ProductID}\t{r.Comments}")
- SaharRad1 year agoRegular Visitor
Thank you for the response.
I followed all the suggested steps:
- Confirmed DNS and network connectivity (nslookup, Test-NetConnection).
- Verified I have ODBC Driver 18 and pyodbc installed.
- Ran my Python script with ActiveDirectoryInteractive and also tried other auth methods.
- Checked my Azure tenant and found I have no valid subscription assigned or active.
It turns out my subscription status is causing the issue. I don’t have any active Azure subscription in my tenant.
- dlevy1 year agoMicrosoft Employee
Oh, yep...that will do it. 😀
If it is a personal tenant then it is easy enough to create a subscription. If you are worried about accidental spending then just use a visa gift card to get started. You can always switch it out later.
For a work tenant that's probably going to require a meeting or at least a few well worded emails.