dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.42k stars 791 forks source link

Maybe this is how to get Azure Integrated auth #8615

Open potatoqualitee opened 1 year ago

potatoqualitee commented 1 year ago

Summarize Functionality

https://learn.microsoft.com/en-us/sql/connect/ado-net/introduction-microsoft-data-sqlclient-namespace?view=sql-server-ver15#new-connection-string-property-synonyms

Is there a command that is similiar or close to what you are looking for?

Yes

Technical Details

No response

wsmelton commented 1 year ago

I'm not 100% sure on how this works but I'm able to authenticate to an Azure SQL MI instance without any special token use in 1.1.143.

I cleared my Az context, cleared the Az CLI session and ran the following:

$sqlcn = Connect-DbaInstance -SqlInstance '<servername>.<uniqueID>.database.windows.net,1433' -EncryptConnection -Tenant <prod tenant ID>

The only thing I have an active session going to the MI is via Azure Data Studio. I never issued New-DbaAzAccessToken or anything. If I call either of the following in my current session this was done in I get the normal "please login first" message:

Verified on the server object that ConnectContext does show the expected Authentication=ActiveDirectoryIntegrated in the connection string as well.

potatoqualitee commented 1 year ago

i removed the 2.0 tag bc it doesnt seem pressing