Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write-DbaDbTableData: Fix for connections to Azure SQL Database with AccessToken #9401

Merged
merged 6 commits into from
Jul 1, 2024

Conversation

andreasjordan
Copy link
Contributor

@andreasjordan andreasjordan commented Jun 20, 2024

Type of Change

  • Bug fix (non-breaking change, fixes write-dbadbdatatable - cannot use connection created by connect-dbainstance #9394 )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

See issue for details.

Also included in this pull request:

  • Import-DbaCsv is now also supported, as I removed the all the StatementTimeout 0 as they are the default anyway.
  • Added a note in the documentation of AccessToken in Connect-DbaInstance on which commands are supported.

@andreasjordan
Copy link
Contributor Author

Import-DbaCsv has the same problems - because it uses Connect-DbaInstance with -StatementTimeout 0. That forces a .ConnectionContext.Copy() and that does not work with a token.

Will try to find a good solution for all of those commands.

@andreasjordan
Copy link
Contributor Author

No, it's $connContext.GetDatabaseConnection($Database) that is the problem. Will have to test if this is needed...

@andreasjordan
Copy link
Contributor Author

OK, I have to do more tests. Will do this in the next days...

@andreasjordan andreasjordan marked this pull request as draft June 20, 2024 19:11
@andreasjordan
Copy link
Contributor Author

Not .GetDatabaseConnection($Database) is the problem, but .ConnectionContext.Copy(). This creates a new connection which fails in case the original connection was opened using AccessToken.

Bottom line: $server from $server = Connect-DbaInstance ... -AccessToken must not be changed by any Connect-DbaInstance inside of our commands.

@andreasjordan andreasjordan marked this pull request as ready for review June 22, 2024 13:58
@potatoqualitee
Copy link
Member

Thank you, will take some time to review this one

@potatoqualitee
Copy link
Member

Well it wont take a long time, just will check it out more deeply tomorrow 😅

@potatoqualitee
Copy link
Member

im happy to merge this but how will we handle timeouts? i imagine the timeouts were adding for expected long-running queries. should we advise updating their configs?

@potatoqualitee potatoqualitee merged commit fe48ad8 into development Jul 1, 2024
13 checks passed
@potatoqualitee potatoqualitee deleted the WriteDbaDbTableData_fix_for_token branch July 1, 2024 09:46
@potatoqualitee
Copy link
Member

And thank you 🙏🏼

@andreasjordan
Copy link
Contributor Author

As StatementTimeout 0 was and is the default, there are no timeouts. So nothing was changed an that side and there should not be a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

write-dbadbdatatable - cannot use connection created by connect-dbainstance
2 participants