microsoft / SQLServerPSModule

This repo is the home of SQL Server PowerShell Module development.
MIT License
51 stars 1 forks source link

[Invoke-ASCmd] ERROR: Could not load type 'Microsoft.Identity.Client.BaseAbstractApplicationBuilder`1' from assembly 'Microsoft.Identity.Client, Version=4.27.0.0, Culture=neutral, PublicKeyToken= #88

Open TymonCzarnota opened 4 months ago

TymonCzarnota commented 4 months ago

Hey 😄

When running:

 [xml] $results = Invoke-ASCmd `
        -Credential $credential `
        -ServicePrincipal `
        -TenantId $azr_svc_tenant_id `
        -InputFile Model_Tabular.xmla `
        -Server $apiUrl `
        2>&1

on version 22.3.0, we are getting following error :

ERROR: Could not load type 'Microsoft.Identity.Client.BaseAbstractApplicationBuilder`1' from assembly 'Microsoft.Identity.Client, Version=4.27.0.0, Culture=neutral, PublicKeyToken=

Code was run from CircleCi and GithubActions and was working fine for older versions. We tried to run the code on different windows runners with the same outcome.

As a workaround we downgraded to 22.2.0 for now

Is this a know issue? Thanks for support 😄

Matteo-T commented 4 months ago

Hi @TymonCzarnota, not known to me. It looks like I some dependency is missing. Are you running into this issue in both PS5.1 and PS7? What versions of PowerShell7 are you on, if the issue happen in PS7?

I'll look into this ASAP and see if I can quickly push out a v22.3.1 with a fix (and also understand why this was not caught when I ran the automation tests).

TymonCzarnota commented 4 months ago

Hey, we've only run it on 5.1, did not test it on PS7. Thanks for the support 😄

Matteo-T commented 4 months ago

Could you share the version of Az.* cmdlets you happen to have in your machine? Specifically, the Az.Accounts... Is it the latest version (3.0.0)? If it isn't, could you update it and see if the issue goes away. I'm still trying to setup an Azure AS in the meanwhile...

TymonCzarnota commented 4 months ago

We are using a windows-latest image from github actions, which seems to come with version 2.1.0 pre-installed. I tried to update to latest (3.0.1 released a day ago 🤔 ), but problem remains. Will try to tinker some more with versions. @Edgar-Kalkowski how does it look like on CircleCi front?

Edgar-Kalkowski commented 4 months ago

On CircleCI Get-Module -ListAvailable -Refresh does not show Az.Accounts as being installed at all. Is it a dependency of the SqlServer module?

Edgar-Kalkowski commented 4 months ago

I tried anyway to install version 3.0.1 of Az.Accounts but I still get the same error.

Matteo-T commented 4 months ago

@Edgar-Kalkowski / @TymonCzarnota - I do not see anything in the SQLServer module that is referencing that (ancient) Microsoft.Identity.Client, Version=4.27.0.0.

Is it possible you have some other (old) module loaded in the PoweShell.exe process, which may be interfering?

[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.Location -like '*Microsoft.Identity.Client.dll' } | ForEach-Object { $_.Location }

Once thing you can try could be to make sure you Import-Module SQLServer before any other (or at least before the one that is loading the old Microsoft.Identity.Client.

SnehilMittal-gep commented 4 months ago

Hi @Matteo-T, Facing the same issue.

This is something related to SqlServer Version 22.3.0.

We isolated and tried lower version of SqlServer 22.2.0. It worked.

We added below command in script to try lower version - @TymonCzarnota You can try this as a temporary workaround.

Get-Module SqlServer -ListAvailable Remove-Item (Get-Module -ListAvailable SQLServer*).Path Install-Module SqlServer -RequiredVersion 22.2.0 -AllowClobber -Confirm:$false -Force Get-Module SqlServer -ListAvailable

Edgar-Kalkowski commented 4 months ago

We did some more investigation of this and it turns out that we were missing an explicit Import-Module SqlServer in our code. Before version 22.3.0 it seems everything worked even without the import. Since that version the import seems to be required to make sure the correct other assemblies are loaded.