Giter Site home page Giter Site logo

Comments (13)

andreasjordan avatar andreasjordan commented on August 19, 2024

Can you run the Write- command with -Verbose and provide the output?

from dbatools.

majst32 avatar majst32 commented on August 19, 2024

VERBOSE: [17:57:03][Write-DbaDbTableData] FQTN processed: [dbo].[redactedTable]

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

Ok, I hoped for more output. I will have a look at the code in the next days and try to provide a workaround or a fix.

from dbatools.

majst32 avatar majst32 commented on August 19, 2024

Thank you!

from dbatools.

majst32 avatar majst32 commented on August 19, 2024

As my workaround I converted my functions to use invoke-dbaquery. It works, but it's messier than I'd like it to be when I have tables with lots of columns.

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

Looking at the code I would expect more verbose output. You are using a pooled connection, so inside of Write-DbaDbTableData, Connect-DbaInstece is called and that command has also verbose output. Do you really only get this one line?

The problem in your case might be, that inside of Write-DbaDbTableData a new connection is opened and not the connection from $server is reused.

It might help to open the connection as non-pooled ($server = Connect-DbaInstance -SqlInstance $azureInstance -Database $azureDatabase -AccessToken $azureToken -NonPooledConnection) because then there is a different code path used inside of Write-DbaDbTableData.

from dbatools.

majst32 avatar majst32 commented on August 19, 2024

I tried creating the $server object as both pooled and non-pooled with the same result. I also used -verbose and -debug and received the same output.

VERBOSE: [14:56:20][Write-DbaDbTableData] FQTN processed: [dbo].[redactedTable]
DEBUG: 88670 | [14:56:20][Write-DbaDbTableData] FQTN processed: [dbo].[redactedTable]
DEBUG: [14:56:20][Write-DbaDbTableData] Failure | Login failed for user ''.

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

I'll try to setup my azure lab to be able to use a token - will probably take some days.

Most probably it has something to do with the way we create the server SMO when using a token. @potatoqualitee do you have a lab where can test that?

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

OK, I can reproduce the error. The line $databaseObject.Tables.Refresh() throws the error. It looks like the "Database" part of the SMO is not filled at all (only "Name" is set). Will do more investigations...

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

The problem is not inside of Write-DbaDbDatatable but inside of Connect-DbaInstance when using -AccessToken. If I connect to the same Azure SQL Database with username and password, it works perfectly.

To test, run $server.Databases.Tables.Count. It should return the number of tables in the database, but returns nothing if the connection is made with access token.

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

For more information about AccessToken see this issue from 2019: #5445

As we only use the SMO inside of Write-DbaDbDatatable to test if the table (and the schema) exists, I changed this to just test the table by running a select against it.

Will open a PR soon.

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

My PR has some side effects - other tests fail now. I have to do more tests. Will do this in the next days...

from dbatools.

andreasjordan avatar andreasjordan commented on August 19, 2024

I now have a working version of the pull request. Waiting for the review and merge...

from dbatools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.