Comments (9)
@potatoqualitee I'm not sure this question is related to this code repo, at least I can't immediately see the direct relationship.
@Matteo-T @shueybubbles do you have more context on this question?
from sqltoolsservice.
Yeah - unrelated to this repo.
Could @potatoqualitee (aka Chrissy) elaborate on the "sometimes"? And, more importantly, on some SMO code that is being executed behind the scenes?
Probably easier to ping me and @shueybubbles directly (it seems a SMO thingie).
from sqltoolsservice.
@kburtram - my apologies, I saw some SMO related questions and thought this would be the place.
@Matteo-T Yes, I can elaborate on sometimes.
This will succeed 100% of the time:
$azSqlCn = Connect-DbaInstance @params
$azSqlCn.Databases.Name
This will fail 100% of the time with the blank login failure:
Get-DbatoolsLog | Select -First 1 | Write-DbaDataTable -SqlInstance $azSqlCn -Database abc -Table ThisisErrorLog -AutoCreateTable
In the future, shall I just ping you guys from the dbatools repo?
Thanks,
Chrissy
from sqltoolsservice.
Not sure how effective that is going to be: I get way too much traffic from GitHub and it is easy for me to miss communications. The important thing, IMHO, is that if this is a SMO issue (under the hood), you should give me/David/etc something that is SMO code ore than asking us to dig into the implementation of the DbaTools module (it does not have to be C# code, PowerShell is fine. But make it look like a few lines of .NET/SMO code).
from sqltoolsservice.
Thanks
$accesstoken = "bigolaccesstoken"
$databasename = "abc"
$connstring = 'Data Source=TCP:psdbatools.database.windows.net,1433;Initial Catalog=abc;Persist Security Info=True;MultipleActiveResultSets=False;Connect Timeout=30;Encrypt=True;TrustServerCertificate=False;Application Name="dbatools PowerShell module - dbatools.io"'
$sqlconn = New-Object System.Data.SqlClient.SqlConnection $connstring
$sqlconn.AccessToken = $AccessToken
$serverconn = New-Object Microsoft.SqlServer.Management.Common.ServerConnection $sqlconn
$null = $serverconn.Connect()
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $serverconn
# works
$server.Databases.Name
# also works
$db = $server.Databases[$databaseName]
$db.Name
# breaks
$db.Tables.Name
# also breaks
$db.Tables.Refresh()
breaks with:
The following exception occurred while trying to enumerate the collection: "Failed to connect to server TCP:psdbatools.database.windows.net,1433.".
and more detailed
PSMessageDetails :
Exception : System.Management.Automation.ExtendedTypeSystemException: The following exception occurred while trying to enumerate the collection: "Failed to
connect to server TCP:psdbatools.database.windows.net,1433.". ---> Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to
connect to server TCP:psdbatools.database.windows.net,1433. ---> System.Data.SqlClient.SqlException: Login failed for user ''.
from sqltoolsservice.
If you can use .Net 4.7.2, I recommend using 'Authentication=Active Directory Interactive' in the connection string, and install a SqlAuthenticationProvider implementation to provide the token. Look up SqlAuthenticationProvider.SetProvider.
Otherwise, the only way the ServerConnection object can assign an access token to SqlConnection objects it creates is if you pass in an IRenewableToken implementation to its constructor.
SMO sometimes creates new connections behind your back, which leads to these errors if you don't use either Interactive auth or IRenewableToken.
from sqltoolsservice.
Thanks shuey! I'll take a look.
from sqltoolsservice.
can confirm this appraoch works! (from azurevm, still trying to get it using a SqlAuthenticationProvider implementation
from sqltoolsservice.
Got it using SqlAuthenticationProvider as well 💯 incredibly fast!
from sqltoolsservice.
Related Issues (20)
- Provide SMO database properties values to the Options tab
- Get server properties
- Provide SMO database properties values to the Database Scoped Configurations tab
- "Save as CSV" does not remove CR from data
- why does the application name always add "-azdata" suffix HOT 3
- Provide SMO database properties values to the Files Tab
- Enable script option for Server Properties tabs
- Review all service errors are logged and inner exception is included where possible HOT 1
- Provide SMO database properties experience to the Filegroups Tab
- Microsoft.Data.Tools.Schema.SqlTasks.targets missing from .NET 7 HOT 1
- Provide SMO database properties experience to the QueryStore Tab
- Validate all properties dropdown options for Localization
- Add condition to verify processors old values with new values
- Query store tab wait statistics option should be changed as Dropdown instead of chekbox
- Move Restore Dialog to MSSQL extension
- Add URL support to new Restore dialog for MI server
- Notebook Agent Jobs fail on named instances
- Supporting materialized views in Kusto
- Error: Request error: UNABLE_TO_GET_ISSUER_CERT_LOCALLY HOT 1
- System.Exception: SpecifiedUri does not have existing connection.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqltoolsservice.