Open ittchmh opened 3 years ago
@dingmeng-xue , @erich-wang
The 'Microsoft.Identity.Client' load is handled by Azure Powershell framework, see link. Would you please help to look?
@ittchmh I see you use Az.Storage 3.3.0. What's the Az.Accounts version do you use? Would you like try to see if the issue can repro on latest Az.Accounts 2.2.6 (Az.Storage can be 3.3.0 or 3.4.0)?
I can't repro it with Az.Accounts 2.2.6 + Az.Storage 3.3.0. I can repro it with Az.Accounts 2.2.5 + Az.Storage 3.3.0.
It might caused by 'Microsoft.Identity.Client' is upgraded to 4.23.0.0 in latest Az.Accounts (2.2.6) with PR https://github.com/Azure/azure-powershell/pull/14228.
@blueww
I upgraded Az.Accounts to 2.2.6, now it works if Az.Storage is imported before Connection to Exchange Online but if I connect to Exchange Online before Az.Storage module imported, Az.Storage module import fails with error
Import-Module: Assembly with same name is already loaded
I checking loaded assembly with code:
$obj = @()
[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object location | ForEach-Object FullN* | ForEach-Object {
$temp = $_ -split ','
$props = [ordered]@{
name = $temp[0]
version = ($temp[1] -split "=")[1]
Culture = ($temp[2] -split "=")[1]
PublicKeyToken = ($temp[3] -split "=")[1]
}
$obj += New-Object PsObject -Property $props
}
$obj | Where-Object {$_.Name -like "Microsoft.Identity.Client*"}
After Az.Accounts upgraded, now it use the same version of 'Microsoft.Identity.Client' 4.23.0.0 - same as ExchangeOnlineManagement, but Az.Storage module can not be loaded if session connected to Exchange Online
I think it's not Az.Account issue, it's Az.Storage issue, because I can connect to Azure successfully
Connect-SRAzureAD is wrapper around Connect-AzAccount cmdlet
@ittchmh Could you workaround it by first import Az.Storage, then Connection to Exchange Online, before the issue is fixed?
For which module has the issue: The shared Assemblies (e.g. "Microsoft.Identity.Client") are handled by Az.Accounts code, anyway, Az.Accounts cmdlets might not use them, so you can run cmdlets in Az.Accounts. The error happen when Az.Storage import, since Az.Storage use it (Az.Storage depends on Az.Accounts).
But the code to handle the "Microsoft.Identity.Client" is still in Az.Accounts. @erich-wang would you please help to look?
Please execute [System.AppDomain]::CurrentDomain.GetAssemblies()
before Import-Module Az.Storage
. It listed all assemblies in process.
@blueww Thank you for help!
Yes, I already loading Az.Storage before connection to Exchange Online Module load order should not broke something )
Please execute
[System.AppDomain]::CurrentDomain.GetAssemblies()
beforeImport-Module Az.Storage
. It listed all assemblies in process.
Before connection to Exchange Online and Az.Storage import
name version Culture PublicKeyToken
---- ------- ------- --------------
AutoMapper 6.2.2.0 neutral be96cd2c38ef1005
Azure.Core 1.9.0.0 neutral 92742159e12e44c8
Azure.Identity 1.4.0.0 neutral 92742159e12e44c8
Hyak.Common 1.0.0.0 neutral 31bf3856ad364e35
MediatR 8.0.0.0 neutral bb9a41a5e8aaa7e2
Microsoft.ActiveDirectory.Management 10.0.0.0 neutral 31bf3856ad364e35
Microsoft.ApplicationInsights 2.15.0.44797 neutral 31bf3856ad364e35
Microsoft.Azure.Common 2.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.Graph.RBAC 3.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.Management.Authorization 2.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.Management.ManagementGroups 1.1.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.Management.ResourceManager 3.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Authentication 2.2.6.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Authentication.Abstractions 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Authentication.ResourceManager 0.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Authenticators 2.2.6.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Aks 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Authorization 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Compute 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Graph.Rbac 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.KeyVault 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Monitor 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Network 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.PolicyInsights 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.ResourceManager 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Storage.Management 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Clients.Websites 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Cmdlets.Accounts 2.2.6.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Cmdlets.ResourceManager 3.3.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Cmdlets.Resources 3.3.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Cmdlets.Tags 3.3.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Common 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Storage 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Azure.PowerShell.Strategies 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.Bcl.AsyncInterfaces 1.0.0.0 neutral cc7b13ffcd2ddd51
Microsoft.CSharp 5.0.0.0 neutral b03f5f7f11d50a3a
Microsoft.Exchange.Management.AdminApiProvider 17.0.0.0 neutral 31bf3856ad364e35
Microsoft.Exchange.Management.ExoPowershellGalleryModule 17.0.0.0 neutral 31bf3856ad364e35
Microsoft.Exchange.Management.RestApiClient 17.0.0.0 neutral 31bf3856ad364e35
Microsoft.Extensions.Caching.Abstractions 2.2.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Caching.Memory 2.2.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Configuration 2.0.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Configuration.Abstractions 2.0.0.0 neutral adb9793829ddae60
Microsoft.Extensions.DependencyInjection 5.0.0.0 neutral adb9793829ddae60
Microsoft.Extensions.DependencyInjection.Abstractions 2.2.0.0 neutral adb9793829ddae60
Microsoft.Extensions.DependencyInjection.Abstractions 5.0.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Logging 5.0.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Logging.Abstractions 5.0.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Options 5.0.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Options 2.2.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Primitives 2.2.0.0 neutral adb9793829ddae60
Microsoft.Extensions.Primitives 5.0.0.0 neutral adb9793829ddae60
Microsoft.Identity.Client 4.23.0.0 neutral 0a613f4dd989e8ae
Microsoft.Identity.Client.Extensions.Msal 2.16.6.0 neutral 0a613f4dd989e8ae
Microsoft.Management.Infrastructure 1.0.0.0 neutral 31bf3856ad364e35
Microsoft.OData.Client 7.6.3.0 neutral 31bf3856ad364e35
Microsoft.Online.CSE.RestApiPowerShellModule.Instrumentation 17.0.0.0 neutral 31bf3856ad364e35
Microsoft.PowerShell.Commands.Diagnostics 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.PowerShell.Commands.Management 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.PowerShell.Commands.Utility 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.PowerShell.ConsoleHost 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.PowerShell.CoreCLR.Eventing 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.PowerShell.CrossCompatibility 1.19.1.0 neutral null
Microsoft.PowerShell.EditorServices 2.3.0.0 neutral null
Microsoft.PowerShell.EditorServices.Hosting 1.0.0.0 neutral null
Microsoft.PowerShell.EditorServices.VSCode 2.3.0.0 neutral null
Microsoft.PowerShell.MarkdownRender 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.PowerShell.PSReadLine.Polyfiller 1.0.0.0 neutral null
Microsoft.PowerShell.PSReadLine2 2.2.0.0 neutral null
Microsoft.PowerShell.Security 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.Rest.ClientRuntime 2.0.0.0 neutral 31bf3856ad364e35
Microsoft.Rest.ClientRuntime.Azure 3.0.0.0 neutral 31bf3856ad364e35
Microsoft.VisualStudio.Threading 16.7.0.0 neutral b03f5f7f11d50a3a
Microsoft.VisualStudio.Validation 15.3.0.0 neutral b03f5f7f11d50a3a
Microsoft.Win32.Primitives 5.0.0.0 neutral b03f5f7f11d50a3a
Microsoft.Win32.Registry 5.0.0.0 neutral b03f5f7f11d50a3a
Microsoft.Windows.PowerShell.ScriptAnalyzer 1.19.1.0 neutral null
Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules 1.19.1.0 neutral null
Microsoft.WindowsAzure.Storage 9.3.0.0 neutral 31bf3856ad364e35
Microsoft.WindowsAzure.Storage.DataMovement 0.8.1.0 neutral 31bf3856ad364e35
Microsoft.WSMan.Management 7.1.2.0 neutral 31bf3856ad364e35
Microsoft.WSMan.Runtime 7.1.2.0 neutral 31bf3856ad364e35
mscorlib 4.0.0.0 neutral b77a5c561934e089
Nerdbank.Streams 2.6.0.0 neutral cac503e1823ce71c
netstandard 2.1.0.0 neutral cc7b13ffcd2ddd51
Newtonsoft.Json 12.0.0.0 neutral 30ad4fe6b2a6aeed
OmniSharp.Extensions.JsonRpc 0.18.0.0 neutral 6d868dff454e6022
OmniSharp.Extensions.LanguageProtocol 0.18.0.0 neutral 6d868dff454e6022
OmniSharp.Extensions.LanguageServer 0.18.0.0 neutral 6d868dff454e6022
OmniSharp.Extensions.LanguageServer.Shared 0.18.0.0 neutral 6d868dff454e6022
pwsh 7.1.2.0 neutral 31bf3856ad364e35
Serilog 2.0.0.0 neutral 24c2f752a8e58a10
Serilog.Extensions.Logging 2.0.0.0 neutral 24c2f752a8e58a10
Serilog.Sinks.Async 1.4.0.0 neutral 24c2f752a8e58a10
Serilog.Sinks.File 2.0.0.0 neutral 24c2f752a8e58a10
System 4.0.0.0 neutral b77a5c561934e089
System.Buffers 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Collections 5.0.0.0 neutral b03f5f7f11d50a3a
System.Collections.Concurrent 5.0.0.0 neutral b03f5f7f11d50a3a
System.Collections.Immutable 5.0.0.0 neutral b03f5f7f11d50a3a
System.Collections.NonGeneric 5.0.0.0 neutral b03f5f7f11d50a3a
System.Collections.Specialized 5.0.0.0 neutral b03f5f7f11d50a3a
System.ComponentModel 5.0.0.0 neutral b03f5f7f11d50a3a
System.ComponentModel.Primitives 5.0.0.0 neutral b03f5f7f11d50a3a
System.ComponentModel.TypeConverter 5.0.0.0 neutral b03f5f7f11d50a3a
System.Configuration 4.0.0.0 neutral b03f5f7f11d50a3a
System.Configuration.ConfigurationManager 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Console 5.0.0.0 neutral b03f5f7f11d50a3a
System.Core 4.0.0.0 neutral b77a5c561934e089
System.Data 4.0.0.0 neutral b77a5c561934e089
System.Data.Common 5.0.0.0 neutral b03f5f7f11d50a3a
System.Diagnostics.DiagnosticSource 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Diagnostics.FileVersionInfo 5.0.0.0 neutral b03f5f7f11d50a3a
System.Diagnostics.Process 5.0.0.0 neutral b03f5f7f11d50a3a
System.Diagnostics.StackTrace 5.0.0.0 neutral b03f5f7f11d50a3a
System.Diagnostics.Tools 5.0.0.0 neutral b03f5f7f11d50a3a
System.Diagnostics.TraceSource 5.0.0.0 neutral b03f5f7f11d50a3a
System.Diagnostics.Tracing 5.0.0.0 neutral b03f5f7f11d50a3a
System.DirectoryServices 4.0.0.0 neutral b03f5f7f11d50a3a
System.DirectoryServices.Protocols 4.0.0.0 neutral b03f5f7f11d50a3a
System.IO 5.0.0.0 neutral b03f5f7f11d50a3a
System.IO.Compression 5.0.0.0 neutral b77a5c561934e089
System.IO.FileSystem 5.0.0.0 neutral b03f5f7f11d50a3a
System.IO.FileSystem.AccessControl 5.0.0.0 neutral b03f5f7f11d50a3a
System.IO.FileSystem.DriveInfo 5.0.0.0 neutral b03f5f7f11d50a3a
System.IO.FileSystem.Primitives 5.0.0.0 neutral b03f5f7f11d50a3a
System.IO.FileSystem.Watcher 5.0.0.0 neutral b03f5f7f11d50a3a
System.IO.Pipelines 4.0.2.2 neutral cc7b13ffcd2ddd51
System.IO.Pipes 5.0.0.0 neutral b03f5f7f11d50a3a
System.Linq 5.0.0.0 neutral b03f5f7f11d50a3a
System.Linq.Expressions 5.0.0.0 neutral b03f5f7f11d50a3a
System.Management 4.0.0.0 neutral b03f5f7f11d50a3a
System.Management.Automation 7.1.2.0 neutral 31bf3856ad364e35
System.Memory 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Memory.Data 1.0.1.0 neutral cc7b13ffcd2ddd51
System.Net.Http 5.0.0.0 neutral b03f5f7f11d50a3a
System.Net.Mail 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Net.NameResolution 5.0.0.0 neutral b03f5f7f11d50a3a
System.Net.NetworkInformation 5.0.0.0 neutral b03f5f7f11d50a3a
System.Net.Primitives 5.0.0.0 neutral b03f5f7f11d50a3a
System.Net.Security 5.0.0.0 neutral b03f5f7f11d50a3a
System.Net.Sockets 5.0.0.0 neutral b03f5f7f11d50a3a
System.Net.WebClient 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Numerics.Vectors 5.0.0.0 neutral b03f5f7f11d50a3a
System.ObjectModel 5.0.0.0 neutral b03f5f7f11d50a3a
System.Private.CoreLib 5.0.0.0 neutral 7cec85d7bea7798e
System.Private.DataContractSerialization 5.0.0.0 neutral b03f5f7f11d50a3a
System.Private.ServiceModel 4.7.0.0 neutral b03f5f7f11d50a3a
System.Private.Uri 5.0.0.0 neutral b03f5f7f11d50a3a
System.Private.Xml 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Private.Xml.Linq 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Reactive 4.4.0.0 neutral 94bc3704cddfc263
System.Reflection.DispatchProxy 5.0.0.0 neutral b03f5f7f11d50a3a
System.Reflection.Emit 5.0.0.0 neutral b03f5f7f11d50a3a
System.Reflection.Emit.ILGeneration 5.0.0.0 neutral b03f5f7f11d50a3a
System.Reflection.Emit.Lightweight 5.0.0.0 neutral b03f5f7f11d50a3a
System.Reflection.Metadata 5.0.0.0 neutral b03f5f7f11d50a3a
System.Reflection.Primitives 5.0.0.0 neutral b03f5f7f11d50a3a
System.Reflection.TypeExtensions 5.0.0.0 neutral b03f5f7f11d50a3a
System.Resources.ResourceManager 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.CompilerServices.Unsafe 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.Extensions 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.InteropServices 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.InteropServices.RuntimeInformation 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.Loader 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.Numerics 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.Serialization 4.0.0.0 neutral b77a5c561934e089
System.Runtime.Serialization.Formatters 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.Serialization.Primitives 5.0.0.0 neutral b03f5f7f11d50a3a
System.Runtime.Serialization.Xml 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.AccessControl 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.Claims 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.Cryptography.Algorithms 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.Cryptography.Encoding 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.Cryptography.Primitives 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.Cryptography.ProtectedData 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.Cryptography.X509Certificates 5.0.0.0 neutral b03f5f7f11d50a3a
System.Security.Permissions 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Security.Principal.Windows 5.0.0.0 neutral b03f5f7f11d50a3a
System.ServiceModel 4.0.0.0 neutral b77a5c561934e089
System.ServiceModel.NetTcp 4.7.0.0 neutral b03f5f7f11d50a3a
System.ServiceModel.Primitives 4.7.0.0 neutral b03f5f7f11d50a3a
System.Text.Encoding 5.0.0.0 neutral b03f5f7f11d50a3a
System.Text.Encoding.CodePages 5.0.0.0 neutral b03f5f7f11d50a3a
System.Text.Encoding.Extensions 5.0.0.0 neutral b03f5f7f11d50a3a
System.Text.Encodings.Web 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Text.Json 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Text.RegularExpressions 5.0.0.0 neutral b03f5f7f11d50a3a
System.Threading 5.0.0.0 neutral b03f5f7f11d50a3a
System.Threading.Overlapped 5.0.0.0 neutral b03f5f7f11d50a3a
System.Threading.Tasks 5.0.0.0 neutral b03f5f7f11d50a3a
System.Threading.Tasks.Extensions 5.0.0.0 neutral cc7b13ffcd2ddd51
System.Threading.Tasks.Parallel 5.0.0.0 neutral b03f5f7f11d50a3a
System.Threading.Thread 5.0.0.0 neutral b03f5f7f11d50a3a
System.Threading.ThreadPool 5.0.0.0 neutral b03f5f7f11d50a3a
System.Xml 4.0.0.0 neutral b77a5c561934e089
System.Xml.ReaderWriter 5.0.0.0 neutral b03f5f7f11d50a3a
System.Xml.XDocument 5.0.0.0 neutral b03f5f7f11d50a3a
System.Xml.XmlSerializer 5.0.0.0 neutral b03f5f7f11d50a3a
Is there any update for this issue? In my case, I create 2 functions in same Function App.
HttpTrigger1/run.ps1
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
Get-AzStorageAccount -ResourceGroupName "myResourceGroup" -Name "myStorage"
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = "body"
})
HttpTrigger2/run.ps1
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
Import-Module "ExchangeOnlineManagement"
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = "body"
})
requirements.psd1
@{
'Az' = '5.*'
}
When I called HttpTrigger1 it will be successfully call Get-AzStorageAccount
But when I called HttpTrigger1 after HttpTrigger2 below error will thrown
ERROR: The 'Get-AzStorageAccount' command was found in the module 'Az.Storage', but the module could not be loaded. For more information, run 'Import-Module Az.Storage'.
I'm seeing the same things things with the current versions of Az.Storage
(5.10.0) and ExchangeOnlineManagement
(3.3.0)
PowerShell 7.3.6
PS C:\Users\jole001> Import-Module ExchangeOnlineManagement
PS C:\Users\jole001> Connect-ExchangeOnline -UserPrincipalName $myupn
PS C:\Users\jole001> $mailbox = get-exomailbox $anymbalias
PS C:\Users\jole001> Import-Module Az.Storage
Import-Module: Assembly with same name is already loaded
And if I do it the other way around
PowerShell 7.3.6
Current User All Hosts
PS C:\Users\jole001> import-module Az.Accounts
PS C:\Users\jole001> import-module Az.Storage
PS C:\Users\jole001> import-module ExchangeOnlineManagement -UserPrincipalName $myupn
PS C:\Users\jole001> get-exomailbox $anymbalias
Get-EXOMailbox: Could not load file or assembly 'Microsoft.OData.Core, Version=7.15.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)
I'm able to replicate in locally in PowerShell 7.3.6 and in an Azure Automation 7.2 runspace.
I can get the results to change slightly if I swap in the Microsoft.OData.Core.dll
and Microsoft.Odata.Edm.dll
files from ExchangeOnlineManagement
to the Az.Storage
module, but I still end with a fatal error:
Get-EXOMailbox: The type initializer for 'Microsoft.OData.Client.TypeSystem' threw an exception.
PS C:\Users\jole001> get-error
Exception :
Type : System.TypeInitializationException
TypeName : Microsoft.OData.Client.TypeSystem
TargetSite :
Name : GetElementType
DeclaringType : Microsoft.OData.Client.TypeSystem, Microsoft.OData.Client, Version=7.15.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : Microsoft.OData.Client.dll
Message : The type initializer for 'Microsoft.OData.Client.TypeSystem' threw an exception.
InnerException :
Type : System.IO.FileLoadException
Message : Could not load file or assembly 'Microsoft.Spatial, Version=7.15.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)
FileName : Microsoft.Spatial, Version=7.15.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
TargetSite : Void .cctor()
InnerException :
Type : System.IO.FileLoadException
Message : Could not load file or assembly 'Microsoft.Spatial, Version=7.15.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
TargetSite :
Name : <LoadFromPath>g____PInvoke|5_0
DeclaringType : System.Runtime.Loader.AssemblyLoadContext
MemberType : Method
Module : System.Private.CoreLib.dll
Source : System.Private.CoreLib
HResult : -2146232799
StackTrace :
at System.Runtime.Loader.AssemblyLoadContext.<LoadFromPath>g____PInvoke|5_0(IntPtr ptrNativeAssemblyBinder, UInt16*
ilPath, UInt16* niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly
assembly, String name)
Source : Microsoft.OData.Client
HResult : -2146232799
StackTrace :
at Microsoft.OData.Client.TypeSystem..cctor()
Source : Microsoft.OData.Client
HResult : -2146233036
StackTrace :
at Microsoft.OData.Client.TypeSystem.GetElementType(Type seqType)
at Microsoft.OData.Client.QueryableResourceExpression.CreateCloneWithNewType(Type type)
at Microsoft.OData.Client.ResourceBinder.StripConvert(Expression e, Type selfDefinedConvertType)
at Microsoft.OData.Client.ResourceBinder.AnalyzeAddCustomQueryOption(MethodCallExpression mce)
at Microsoft.OData.Client.ResourceBinder.VisitMethodCall(MethodCallExpression mce)
at Microsoft.OData.Client.ALinqExpressionVisitor.Visit(Expression exp)
at Microsoft.OData.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at Microsoft.OData.Client.ResourceBinder.Bind(Expression e, DataServiceContext context)
at Microsoft.OData.Client.DataServiceQueryProvider.Translate(Expression e)
at Microsoft.OData.Client.DataServiceQuery`1.Translate()
at Microsoft.OData.Client.DataServiceQuery`1.get_RequestUri()
at Microsoft.Exchange.Management.AdminApiProvider.ApiProvider`1.InvokeRestApiWithRetry(DataServiceQuery`1
cmdletQuery)+MoveNext()
at Microsoft.Exchange.Management.AdminApiProvider.AsyncJobController`1.<>c__DisplayClass12_0.<InvokeQuery>b__0(ApiProv
ider`1 apiProvider)
at Microsoft.Exchange.Management.AdminApiProvider.ApiProvider`1.InvokeQuery(ApiProviderContext`1 apiProviderContext,
Func`2 responseHandler)
at Microsoft.Exchange.Management.AdminApiProvider.AsyncJobController`1.InvokeQuery(ApiProviderContext`1 queryContext,
Action`1 writeObject, Action`1 writeError)
at Microsoft.Exchange.Management.AdminApiProvider.AsyncJobController`1.InvokeTask(ApiProviderContext`1 queryContext,
Action`1 writeObject, Action`1 writeError)
at Microsoft.Exchange.Management.RestApiClient.GetExoMailbox.InternalProcessRecord()
at Microsoft.Exchange.Management.RestApiClient.AdminCmdlet`2.ProcessRequest()
at Microsoft.Exchange.Management.RestApiClient.AdminCmdlet`2.<ProcessRecord>b__34_0()
at Microsoft.Exchange.Management.RestApiClient.AdminCmdlet`2.ExecuteWithExceptionHandling(Action action, Exception&
exception)
CategoryInfo : ProtocolError: (:) [Get-EXOMailbox], TypeInitializationException
FullyQualifiedErrorId : The type initializer for 'Microsoft.OData.Client.TypeSystem' threw an
exception.,Microsoft.Exchange.Management.RestApiClient.GetExoMailbox
InvocationInfo :
MyCommand : Get-EXOMailbox
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 4
Line : get-exomailbox $anymbalias
PositionMessage : At line:1 char:1
+ get-exomailbox $anymbalias
+ ~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : get-exomailbox
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
Ok, thank you Get-Error
. What the heck, let's copy Microsoft.Spatial.dll
from ExchangeOnlineManagement
to Az.Storage
and let's see what happens!
PS C:\Users\jole001> import-module Az.Storage
PS C:\Users\jole001> Import-Module ExchangeOnlineManagement
PS C:\Users\jole001> Connect-ExchangeOnline -UserPrincipalName$myupn
PS C:\Users\jole001> get-exomailbox $anymbalias
ExternalDirectoryObjectId : <actual results redacted>
UserPrincipalName :
Alias :
DisplayName :
EmailAddresses :
PrimarySmtpAddress :
RecipientType :
RecipientTypeDetails :
Identity :
Id :
ExchangeVersion :
Name :
DistinguishedName :
OrganizationId :
Guid :
Success!!!
So this leads me to think that the core problem may be that the Azure team has decided to continue using an older version of these dlls while the Exchange team decided to use a much more current version.
Adding some context to the dependencies:
Microsoft.Azure.Cosmos.Table
v1.0.8 -> Microsoft.OData.Core
v7.6.4
Microsoft.OData.Core
v7.6.4 -> Microsoft.Spatial
v7.6.4
Microsoft.OData.Core
v7.6.4 -> Microsoft.OData.Edm
v7.6.4
Microsoft.Azure.Cosmos.Table
(and other Microsoft.Azure.*
storage libraries) are deprecated. This is why it isn't getting fixed. The code needs to be upgraded to use Azure.Data.Tables
alone.
What can we do to get more traction on this? This is still an ongoing issue and as noted above it's basically a show-stopper to trying to use Az.Storage and ExchangeOnlineManagement in the same PowerShell session -- which ever one you load first will work and then the other one will break until you unload the conflicting module. It's not a reasonable workaround for us to be manually replacing dependency DLLs with updated versions everytime we install an updated version of Az.Storage.
In case anyone runs into this issue and they're using Azure Automation, just to save anyone some time, the following won't work (at least, not in PS 7.2):
It sounds like even today the only workaround is replacing .dll files...
Any updates on this? It's difficult to automate and remove overhead for your company when you're limited by overlapping dependancies... can't implement my function apps and automations.
@WayneAtMicrosoft , @jangukin
As you are the table cmdlets owner, would you please help to see how to remove the deprecated dependency SDK Microsoft.Azure.Cosmos.Table from Azure Powershell dependency.
I am currently researching and leveraging this as a potential work around, whomever may need it:
Description
ExchangeOnlineManagement failed to load after Az.Storage loaded
Error:
Loaded assembly:
Az.Storage failed to load after ExchangeOnlineManagement loaded
Loaded assembly:
Steps to reproduce
or
Environment data
Module versions
Debug output
Error output