Azure / Azure/azure-powershell
Az.Storage failed to load after ExchangeOnlineManagement and vice-versa
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
## Description
**ExchangeOnlineManagement failed to load after Az.Storage loaded**
Error:
```powershell
Import-Module -Name Az.Storage
Connect-ExchangeOnline -Credential $o365Creds -ShowProgress $true
New-ExoPSSession: ~\Documents\PowerShell\Modules\ExchangeOnlineManagement\2.0.4\netCore\ExchangeOnlineManagement.psm1:475:30
Line |
475 | … PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Could not load file or assembly 'Microsoft.Identity.Client, Version=4.23.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Could not find or load a specific file.
| (0x80131621)
```
Loaded assembly:
```powershell
name version Culture PublicKeyToken
---- ------- ------- --------------
Microsoft.Identity.Client 4.21.0.0 neutral 0a613f4dd989e8ae
```
**Az.Storage failed to load after ExchangeOnlineManagement loaded**
```powershell
Connect-ExchangeOnline -Credential $o365Creds -ShowProgress $true
Import-Module -Name Az.Storage
Import-Module: Assembly with same name is already loaded
```
Loaded assembly:
```powershell
name version Culture PublicKeyToken
---- ------- ------- --------------
Microsoft.Identity.Client 4.23.0.0 neutral 0a613f4dd989e8ae
```
## Steps to reproduce
```powershell
Connect-ExchangeOnline -Credential $o365Creds -ShowProgress $true
Import-Module -Name Az.Storage
```
or
```powershell
Import-Module -Name Az.Storage
Connect-ExchangeOnline -Credential $o365Creds -ShowProgress $true
```
## Environment data
```
Name Value
---- -----
PSVersion 7.1.2
PSEdition Core
GitCommitId 7.1.2
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
## Module versions
```powershell
Version Name
------- ----
3.3.0 Az.Storage
2.0.4 ExchangeOnlineManagement
```
## Debug output
```
```
## Error output
```
Resolve-AzError
DEBUG: Sought all Az modules and got latest version 5.5.0
DEBUG: 15:40:17 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 15:40:17 - using account id '----'...
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release. Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
HistoryId: 3
Message : Assembly with same name is already loaded
StackTrace : at System.Management.Automation.Runspaces.InitialSessionState.Bind_LoadAssemblies(ExecutionContext context)
at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local,
Boolean setLocation)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localiz
edData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModu
leOptions& options, Boolean& containedErrors)
Exception : System.IO.FileLoadException
InvocationInfo : {Import-Module}
Line : Import-Module -Name Az.Storage
Position : At line:1 char:1
+ Import-Module -Name Az.Storage
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
DEBUG: AzureQoSEvent: CommandName - Resolve-AzError; IsSuccess - True; Duration - 00:00:00.2181639
DEBUG: Finish sending metric.
DEBUG: 15:40:18 - ResolveError end processing.
```
Contributor guide
Research direction
Start with documentation/troubleshoot-module-load.md and reproduce both import orders using PowerShell 7.1.2, Az.Storage 3.3.0, and ExchangeOnlineManagement 2.0.4. Compare the loaded Microsoft.Identity.Client versions and the reported assembly errors; done means both modules import successfully regardless of which is loaded first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- cloud, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100