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

Connect-DbaInstance breaks Get-AzStorageBlob #9335

Open
david-garcia-garcia opened this issue Apr 27, 2024 · 4 comments
Open

Connect-DbaInstance breaks Get-AzStorageBlob #9335

david-garcia-garcia opened this issue Apr 27, 2024 · 4 comments
Labels
bugs life pending OP feedback Waiting for feedback from the OP of the issue

Comments

@david-garcia-garcia
Copy link
Contributor

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

Very very weird interaction here.

If I call Connect-DbaInstance before using Get-AzStorageBlob, Get-AzStorageBlob will crash;

Azure/azure-powershell#24748

Steps to Reproduce

$sqlInstance = Connect-DbaInstance -SqlInstance "localhost";
$path="https://xxx.blob.core.windows.net/exchange/testbackups/"
$ctx = New-AzStorageContext -StorageAccountName $backupUrl.storageAccountName -SasToken $backupUrl.sasToken;
$blobs = Get-AzStorageBlob -Container $backupUrl.container -Context $ctx -Prefix $backupUrl.prefix;

this does work

$path="https://xxx.blob.core.windows.net/exchange/testbackups/"
$ctx = New-AzStorageContext -StorageAccountName $backupUrl.storageAccountName -SasToken $backupUrl.sasToken;
$blobs = Get-AzStorageBlob -Container $backupUrl.container -Context $ctx -Prefix $backupUrl.prefix;

Please confirm that you are running the most recent version of dbatools

?

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.20348.2227
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.2227
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2022 (RTM-GDR) (KB5035432) - 16.0.1115.1 (X64) Mar 15 2024 01:13:46 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro N 10.0 (Build 22631: ) (Hypervisor)

.NET Framework Version

PSChildName Version


Client 4.8.04161
Full 4.8.04161
Client 4.0.0.0

@david-garcia-garcia david-garcia-garcia added bugs life triage required New issue that has not been reviewed by maintainers labels Apr 27, 2024
@potatoqualitee
Copy link
Member

Seems like this could be conflicting versions of Azure Identity. Can you load dbatools after and see if it still works? If it continues not to work, I don't know how to fix it, unfortunately. Maybe try in Core as it loads DLLs differently (I think)

@wsmelton
Copy link
Member

wsmelton commented Apr 28, 2024

This is by nature of the library version we use for Azure authentication being lower to the one used by Azure PowerShell modules...or version mismatch around APIs hit (could be both or one of the two).

It will likely exists for the other modules that deal with identity auth and not just storage commands.

Maybe you can expand on why you need to use those Az commands with dbatools in the same session?

Also what does "crash" mean?

@andreasjordan
Copy link
Contributor

I can reproduce the issue and the get the error message that is shown in the linked issue. Only importing dbatools is needed, no connection to an instance is needed.

@andreasjordan
Copy link
Contributor

Workaround: Import Az modules first, then dbatools:

Import-Module Az.Accounts, Az.Storage
Import-Module dbatools

Just another example why I always import all modules at the top of the script in the "correct" order...

@andreasjordan andreasjordan added pending OP feedback Waiting for feedback from the OP of the issue and removed triage required New issue that has not been reviewed by maintainers labels Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life pending OP feedback Waiting for feedback from the OP of the issue
Projects
None yet
Development

No branches or pull requests

4 participants