Closed PatrickSpies closed 1 year ago
check it, @wsmelton! when MSFT figures this out, we can too 😅 I know you said it had to do with sqlbulkcopy so i think it'll have to be fixed in the sqlclient.
Still fails with v22.1.1
Same here
Sorry folks. I completely missed this issue.
I do not know on top of my head how to setup all that stuff and my MI is not configured for User Managed Identities.
If you have a script to set it up, it would help me debugging.
The cmdlets are not really doing much: they typically pass around the token to either SMO or the driver (Microsoft.Data.SqlClient). It is possible that the way the Read-Sql* cmdlet is passing the token to SMO is incorrect for some reason; Invoke-Sqlcmd passed the token straight to the driver... so that could be a difference.
What is the behavior if you don't pass the full token object -AccessToken (Get-AzAccessToken -ResourceUrl https://database.windows.net)
instead of just the text blob -AccessToken (Get-AzAccessToken -ResourceUrl https://database.windows.net).Token
: same error?
Also, what is the real error? Can you just capture the $Error[0].Exception.ToString()
and see if it reveals anything interesting?
Sorry for my mistake, it seems the issue had been fixed with v22.1.1 I´ve had an additional issue with multiple az-contexts within the running script.
Both of your variants (with and withoud .Token
are working.
Thanks for confirming!
... as a parent issue is marked as "closed", I shifted a description to a new issue
We are using the new
-AccessToken
-parameter to connect to a database within Azure-Managed-Instance with a user-assigned managed-identity. For some cmdlets this is working as expected, but for others (e.g.Read-SqlTableData
/Write-SqlTableData
) the invokation leads to an error.Using
Invoke-Sqlcmd
with-AccessToken
returns the expected result:Instead using
Read-SqlTableData
with-AccessToken
leads to an error:Same error when using
Write-SqlTableData
When passing the token from my personal azuread-user instead of using the managed-identity the invocation succeeds..
As both
Invoke-Sqlcmd
and using a personal access-token are working properly, we can not see any cause forRead-SqlTableData
/Write-SqlTableData
not working with-AccessToken
and the managed-identity..