Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.25k stars 3.85k forks source link

Connect-AzAccount throws exception in PowerShell Azure Function "System.ArgumentNullException: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. The system cannot find the path specified." #23001

Closed v-bafa closed 11 months ago

v-bafa commented 1 year ago

Description

My PowerShell Azure Function started to fail with the exception below at Connect-AzAccount with SPN from 10/10/2023.

Repro code block

       $SPNClientId = 'xxxxx'
        $TenantId = 'xxxx'
        # Get the client secret forSPN         
        $clientSecret = (Get-AzKeyVaultSecret -VaultName $ENV:SPNKV -Name $ENV:SPNSecret).SecretValue
        # Connect to Azure with SPN
        if ($clientSecret) {  
            [System.AppDomain]::CurrentDomain.GetAssemblies()      
            Write-Host "Connecting to Azure with SPN"
            $creds = [System.Management.Automation.PSCredential]::new($SPNClientId, $clientSecret)
            Connect-AzAccount -Tenant $TenantId -Credential $creds -ServicePrincipal | Out-Null
        }   
2023-10-17 18:00:05.825
OUTPUT: InnerException : False
Information
2023-10-17 18:00:05.825
OUTPUT: Exception : System.ArgumentNullException: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. The system cannot find the path specified.
Information
2023-10-17 18:00:05.827
OUTPUT: Could not find tenant id for provided tenant domain 'xxxxxxxx'. Please ensure that the provided service principal 'xxxxxxxxx' is found in the provided tenant domain.
Information
2023-10-17 18:00:05.827
OUTPUT: ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. The system cannot find the path specified.
Information
2023-10-17 18:00:05.827
OUTPUT: File name: 'Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'
Information
2023-10-17 18:00:05.827
OUTPUT: ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Identity.Client\v4.0_4.51.0.0__0a613f4dd989e8ae'.
Information
2023-10-17 18:00:05.827
OUTPUT: at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
Information
2023-10-17 18:00:05.827
OUTPUT: at System.IO.Enumeration.FileSystemEnumerator`1.Init()
Information
2023-10-17 18:00:05.827
OUTPUT: at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)
Information
2023-10-17 18:00:05.905
OUTPUT: at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Management.Automation.PowerShellAssemblyLoadContext.FindInGac(String gacRoot, AssemblyName assemblyName, String& assemblyPath)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Management.Automation.PowerShellAssemblyLoadContext.TryFindInGAC(AssemblyName assemblyName, String& assemblyFilePath)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Management.Automation.PowerShellAssemblyLoadContext.Resolve(AssemblyLoadContext loadContext, AssemblyName assemblyName)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.IsTransientException(Exception e)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password, String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantIdOrName, String subscriptionId, String subscriptionName, SecureString password, Boolean skipValidation, IOpenIDConfiguration openIDConfigDoc, Action`1 promptAction, String name, Boolean shouldPopulateContextList, Int32 maxContextPopulation, String authScope)
Information
2023-10-17 18:00:05.947
OUTPUT: --- End of inner exception stack trace ---
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantIdOrName, String subscriptionId, String subscriptionName, SecureString password, Boolean skipValidation, IOpenIDConfiguration openIDConfigDoc, Action`1 promptAction, String name, Boolean shouldPopulateContextList, Int32 maxContextPopulation, String authScope)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_2.<ExecuteCmdlet>b__5()
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Threading.Tasks.Task`1.InnerInvoke()
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
Information
2023-10-17 18:00:05.947
OUTPUT: --- End of stack trace from previous location ---
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
Information
2023-10-17 18:00:05.947
OUTPUT: at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
Information
2023-10-17 18:00:05.947
OUTPUT: --- End of stack trace from previous location ---
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_1.<ExecuteCmdlet>b__1(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass136_0.<SetContextWithOverwritePrompt>b__0(AzureRmProfile prof, RMProfileClient client)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
Information
2023-10-17 18:00:05.947
OUTPUT: at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Information

Ran [System.AppDomain]::CurrentDomain.GetAssemblies() and following are the output.

2023-10-17 20:50:19.948
OUTPUT: CodeBase : file:///C:/Program Files (x86)/dotnet/shared/Microsoft.NETCore.App/6.0.23/System.Private.CoreLib.dll
Information
2023-10-17 20:50:19.948
OUTPUT: FullName : System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
Information
2023-10-17 20:50:25.135
OUTPUT: ExportedTypes : {Microsoft.Extensions.Azure.CertificateClientBuilderExtensions, Azure.Security.KeyVault.Certificates.AdministratorContact, Azure.Security.KeyVault.Certificates.CertificateClient, Azure.Security.KeyVault.Certificates.CertificateClientOptions…}
Information
2023-10-17 20:50:25.135
OUTPUT: IsFullyTrusted : True
Information
2023-10-17 20:50:25.135
OUTPUT: CustomAttributes : {[System.Runtime.CompilerServices.ExtensionAttribute()], [System.Runtime.CompilerServices.CompilationRelaxationsAttribute((Int32)8)], [System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True)], [System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute+DebuggingModes)2)]…}
Information
2023-10-17 20:50:25.135
OUTPUT: EscapedCodeBase : file:///C:/home/data/ManagedDependencies/2310010044071717868.r/Az.KeyVault/4.9.3/Azure.Security.KeyVault.Certificates.dll
Information
2023-10-17 20:50:25.135
OUTPUT: Modules : {Azure.Security.KeyVault.Certificates.dll}
Information
2023-10-17 20:50:25.135
OUTPUT: SecurityRuleSet : None
Information
2023-10-17 20:50:25.135
OUTPUT:
Information
2023-10-17 20:50:25.136
OUTPUT:
Information
2023-10-17 20:50:25.136
OUTPUT: CodeBase : file:///C:/home/data/ManagedDependencies/2310010044071717868.r/Az.KeyVault/4.9.3/Azure.Security.KeyVault.Administration.dll
Information
2023-10-17 20:50:25.136
OUTPUT: FullName : Azure.Security.KeyVault.Administration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8
Information
2023-10-17 20:50:25.136
OUTPUT: EntryPoint :
Information
2023-10-17 20:50:25.136
OUTPUT: DefinedTypes :
Information
2023-10-17 20:50:25.136
OUTPUT: IsCollectible : False
Information
2023-10-17 20:50:25.136
OUTPUT: ManifestModule : Azure.Security.KeyVault.Administration.dll
Information
2023-10-17 20:50:25.136
OUTPUT: ReflectionOnly : False
Information
2023-10-17 20:50:25.136
OUTPUT: Location : C:\home\data\ManagedDependencies\2310010044071717868.r\Az.KeyVault\4.9.3\Azure.Security.KeyVault.Administration.dll
Information
2023-10-17 20:50:25.136
OUTPUT: ImageRuntimeVersion : v4.0.30319
Information
2023-10-17 20:50:25.136
OUTPUT: GlobalAssemblyCache : False
Information
2023-10-17 20:50:25.136
OUTPUT: HostContext : 0
Information
2023-10-17 20:50:25.136
OUTPUT: IsDynamic : False
Information
2023-10-17 20:50:25.136
OUTPUT: ExportedTypes : {Azure.Security.KeyVault.Administration.CreateOrUpdateRoleDefinitionOptions, Azure.Security.KeyVault.Administration.KeyVaultAdministrationModelFactory, Azure.Security.KeyVault.Administration.KeyVaultDataAction, Azure.Security.KeyVault.Administration.KeyVaultPermission…}
Information
2023-10-17 20:50:25.136
OUTPUT: IsFullyTrusted : True
Information
2023-10-17 20:50:25.136
OUTPUT: CustomAttributes : {[System.Runtime.CompilerServices.ExtensionAttribute()], [System.Runtime.CompilerServices.CompilationRelaxationsAttribute((Int32)8)], [System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True)], [System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute+DebuggingModes)2)]…}
Information
2023-10-17 20:50:25.136
OUTPUT: EscapedCodeBase : file:///C:/home/data/ManagedDependencies/2310010044071717868.r/Az.KeyVault/4.9.3/Azure.Security.KeyVault.Administration.dll
Information
2023-10-17 20:50:25.136
OUTPUT: Modules : {Azure.Security.KeyVault.Administration.dll}
Information
2023-10-17 20:50:25.136
OUTPUT: SecurityRuleSet : None
Information
2023-10-17 20:50:25.136
OUTPUT:
Information
2023-10-17 20:50:25.358
OUTPUT:
Information
2023-10-17 20:50:25.358
OUTPUT: CodeBase : file:///C:/home/data/ManagedDependencies/2310010044071717868.r/Az.KeyVault/4.9.3/BouncyCastle.Crypto.dll
Information
2023-10-17 20:50:25.358
OUTPUT: FullName : BouncyCastle.Crypto, Version=1.8.8.0, Culture=neutral, PublicKeyToken=0e99375e54769942
Information
2023-10-17 20:50:25.358
OUTPUT: EntryPoint :
Information
2023-10-17 20:50:25.358
OUTPUT: DefinedTypes : {ThisAssembly, AssemblyInfo, crypto.Security, Org.BouncyCastle.Apache.Bzip2.BZip2Constants…}
Information
2023-10-17 20:50:25.358
OUTPUT: IsCollectible : False
Information
2023-10-17 20:50:25.407
OUTPUT: ManifestModule : BouncyCastle.Crypto.dll
Information
2023-10-17 20:50:25.408
OUTPUT: ReflectionOnly : False
Information
2023-10-17 20:50:25.408
OUTPUT: Location : C:\home\data\ManagedDependencies\2310010044071717868.r\Az.KeyVault\4.9.3\BouncyCastle.Crypto.dll
Information
2023-10-17 20:50:25.408
OUTPUT: ImageRuntimeVersion : v4.0.30319
Information
2023-10-17 20:50:25.408
OUTPUT: GlobalAssemblyCache : False
Information
2023-10-17 20:50:25.408
OUTPUT: HostContext : 0
Information
2023-10-17 20:50:25.408
OUTPUT: IsDynamic : False
Information
2023-10-17 20:50:25.408
OUTPUT: ExportedTypes : {crypto.Security, Org.BouncyCastle.Apache.Bzip2.BZip2Constants, Org.BouncyCastle.Apache.Bzip2.CBZip2InputStream, Org.BouncyCastle.Apache.Bzip2.CBZip2OutputStream…}
Information
2023-10-17 20:50:25.408
OUTPUT: IsFullyTrusted : True
Information
2023-10-17 20:50:25.408
OUTPUT: CustomAttributes : {[System.Runtime.CompilerServices.CompilationRelaxationsAttribute((Int32)8)], [System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True)], [System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute+DebuggingModes)2)], [System.Reflection.AssemblyFileVersionAttribute("1.8.8.2")]…}
Information
2023-10-17 20:50:25.408
OUTPUT: EscapedCodeBase : file:///C:/home/data/ManagedDependencies/2310010044071717868.r/Az.KeyVault/4.9.3/BouncyCastle.Crypto.dll
Information
2023-10-17 20:50:25.408
OUTPUT: Modules : {BouncyCastle.Crypto.dll}
Information
2023-10-17 20:50:25.408
OUTPUT: SecurityRuleSet : None
Information
2023-10-17 20:50:25.408
OUTPUT:
Information
2023-10-17 20:50:25.408
OUTPUT:
Information
2023-10-17 20:50:25.408
OUTPUT: CodeBase : file:///C:/home/data/ManagedDependencies/2310010044071717868.r/Az.KeyVault/4.9.3/Microsoft.Azure.PowerShell.Cmdlets.KeyVault.dll
Information
2023-10-17 20:50:25.408
OUTPUT: FullName : Microsoft.Azure.PowerShell.Cmdlets.KeyVault, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Information
2023-10-17 20:50:25.408
OUTPUT: EntryPoint :
Information
2023-10-17 20:50:25.408
OUTPUT: DefinedTypes : {Microsoft.Azure.Commands.Shared.Config.ConfigKeys, Microsoft.Azure.Commands.KeyVault.BackupAzureKeyVaultSecret, Microsoft.Azure.Commands.KeyVault.AddAzureKeyVaultCertificate, Microsoft.Azure.Commands.KeyVault.BackupAzureKeyVaultCertificate…}
Information
2023-10-17 20:50:25.408
OUTPUT: IsCollectible : False
Information
2023-10-17 20:50:25.408
OUTPUT: ManifestModule : Microsoft.Azure.PowerShell.Cmdlets.KeyVault.dll
Information
2023-10-17 20:50:25.408
OUTPUT: ReflectionOnly : False
Information
2023-10-17 20:50:25.408
OUTPUT: Location : C:\home\data\ManagedDependencies\2310010044071717868.r\Az.KeyVault\4.9.3\Microsoft.Azure.PowerShell.Cmdlets.KeyVault.dll
Information
2023-10-17 20:50:25.408
OUTPUT: ImageRuntimeVersion : v4.0.30319
Information
2023-10-17 20:50:25.408
OUTPUT: GlobalAssemblyCache : False
Information
2023-10-17 20:50:25.408
OUTPUT: HostContext : 0
Information
2023-10-17 20:50:25.408
OUTPUT: IsDynamic : False
Information
2023-10-17 20:50:25.408
OUTPUT: ExportedTypes : {Microsoft.Azure.Commands.KeyVault.BackupAzureKeyVaultSecret, Microsoft.Azure.Commands.KeyVault.AddAzureKeyVaultCertificate, Microsoft.Azure.Commands.KeyVault.BackupAzureKeyVaultCertificate, Microsoft.Azure.Commands.KeyVault.AddAzureKeyVaultCertificateContact…}
Information
2023-10-17 20:50:25.408
OUTPUT: IsFullyTrusted : True
Information
2023-10-17 20:50:25.408
OUTPUT: CustomAttributes : {[System.Runtime.CompilerServices.ExtensionAttribute()], [System.Runtime.CompilerServices.CompilationRelaxationsAttribute((Int32)8)], [System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True)], [System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute+DebuggingModes)2)]…}
Information
2023-10-17 20:50:25.408
OUTPUT: EscapedCodeBase : file:///C:/home/data/ManagedDependencies/2310010044071717868.r/Az.KeyVault/4.9.3/Microsoft.Azure.PowerShell.Cmdlets.KeyVault.dll
Information
2023-10-17 20:50:25.408
OUTPUT: Modules : {Microsoft.Azure.PowerShell.Cmdlets.KeyVault.dll}
Information
2023-10-17 20:50:25.408
OUTPUT: SecurityRuleSet : None

Issue script & Debug output

2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'ServicePrincipalWithSubscriptionId'.
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - [ConfigManager] Got nothing from [DefaultSubscriptionForLogin], Module = [], Cmdlet = []. Returning default value [].
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - Autosave setting from startup session: 'Process'
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - No autosave setting detected in environment variable 'AzContextAutoSave'. 
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - Using Autosave scope 'Process'
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - Autosave setting from startup session: 'Process'
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - No autosave setting detected in environment variable 'AzContextAutoSave'. 
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - Using Autosave scope 'Process'
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - [ConfigManager] Got nothing from [DisableErrorRecordsPersistence], Module = [], Cmdlet = []. Returning default value [False].
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - using account id 'xxxxxx'...
2023-10-17T21:07:37Z   [Verbose]   DEBUG: 9:07:37 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
2023-10-17T21:07:38Z   [Information]   OUTPUT: 
2023-10-17T21:07:38Z   [Information]   OUTPUT: InnerException   : False
2023-10-17T21:07:38Z   [Information]   OUTPUT: Exception        : System.ArgumentNullException: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. The system cannot find the path specified.
2023-10-17T21:07:38Z   [Information]   OUTPUT:                    Could not find tenant id for provided tenant domain 'xxxxx'. Please ensure that the provided service principal 'xxxxx' is found in the provided tenant domain.
2023-10-17T21:07:38Z   [Information]   OUTPUT:                     ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. The system cannot find the path specified.
2023-10-17T21:07:38Z   [Information]   OUTPUT:                    File name: 'Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'
2023-10-17T21:07:38Z   [Information]   OUTPUT:                     ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Identity.Client\v4.0_4.51.0.0__0a613f4dd989e8ae'.
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.IO.Enumeration.FileSystemEnumerator`1.Init()
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.IO.Directory.EnumerateFiles(String path, String searchPattern)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Management.Automation.PowerShellAssemblyLoadContext.FindInGac(String gacRoot, AssemblyName assemblyName, String& assemblyPath)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Management.Automation.PowerShellAssemblyLoadContext.TryFindInGAC(AssemblyName assemblyName, String& assemblyFilePath)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Management.Automation.PowerShellAssemblyLoadContext.Resolve(AssemblyLoadContext loadContext, AssemblyName assemblyName)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.IsTransientException(Exception e)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password, String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantIdOrName, String subscriptionId, String subscriptionName, SecureString password, Boolean skipValidation, IOpenIDConfiguration openIDConfigDoc, Action`1 promptAction, String name, Boolean shouldPopulateContextList, Int32 maxContextPopulation, String authScope)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       --- End of inner exception stack trace ---
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantIdOrName, String subscriptionId, String subscriptionName, SecureString password, Boolean skipValidation, IOpenIDConfiguration openIDConfigDoc, Action`1 promptAction, String name, Boolean shouldPopulateContextList, Int32 maxContextPopulation, String authScope)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_2.<ExecuteCmdlet>b__5()
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Threading.Tasks.Task`1.InnerInvoke()
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                    --- End of stack trace from previous location ---
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                    --- End of stack trace from previous location ---
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_1.<ExecuteCmdlet>b__1(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass136_0.<SetContextWithOverwritePrompt>b__0(AzureRmProfile prof, RMProfileClient client)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
2023-10-17T21:07:38Z   [Information]   OUTPUT:                       at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()

Environment data

023-10-17T21:12:37Z   [Information]   OUTPUT: Name                           Value
2023-10-17T21:12:37Z   [Information]   OUTPUT: ----                           -----
2023-10-17T21:12:37Z   [Information]   OUTPUT: PSVersion                      7.2.13
2023-10-17T21:12:37Z   [Information]   OUTPUT: PSEdition                      Core
2023-10-17T21:12:37Z   [Information]   OUTPUT: GitCommitId                    7.2.13
2023-10-17T21:12:37Z   [Information]   OUTPUT: OS                             Microsoft Windows 10.0.20348
2023-10-17T21:12:37Z   [Information]   OUTPUT: Platform                       Win32NT
2023-10-17T21:12:37Z   [Information]   OUTPUT: PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
2023-10-17T21:12:37Z   [Information]   OUTPUT: PSRemotingProtocolVersion      2.3
2023-10-17T21:12:37Z   [Information]   OUTPUT: SerializationVersion           1.1.0.1
2023-10-17T21:12:37Z   [Information]   OUTPUT: WSManStackVersion              3.0

Module versions

2023-10-17T21:14:40Z   [Information]   OUTPUT: Name              : Az.Accounts
2023-10-17T21:14:40Z   [Information]   OUTPUT: Path              : C:\home\data\ManagedDependencies\2310010044071717868.r\Az.Accounts\2.13.1\Az.Accounts.psm1
2023-10-17T21:14:40Z   [Information]   OUTPUT: Description       : Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
2023-10-17T21:14:40Z   [Information]   OUTPUT:                     
2023-10-17T21:14:40Z   [Information]   OUTPUT:                     For more information on account credential management, please visit the following: https://learn.microsoft.com/powershell/azure/authenticate-azureps
2023-10-17T21:14:40Z   [Information]   OUTPUT: Guid              : 17a2feff-488b-47f9-8729-e2cec094624c
2023-10-17T21:14:40Z   [Information]   OUTPUT: Version           : 2.13.1
2023-10-17T21:14:40Z   [Information]   OUTPUT: ModuleBase        : C:\home\data\ManagedDependencies\2310010044071717868.r\Az.Accounts\2.13.1
2023-10-17T21:14:40Z   [Information]   OUTPUT: ModuleType        : Script
2023-10-17T21:14:40Z   [Information]   OUTPUT: PrivateData       : {PSData}
2023-10-17T21:14:40Z   [Information]   OUTPUT: AccessMode        : ReadWrite
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedAliases   : {[Add-AzAccount, Add-AzAccount], [Get-AzDomain, Get-AzDomain], [Invoke-AzRest, Invoke-AzRest], [Login-AzAccount, Login-AzAccount]…}
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedCmdlets   : {[Add-AzEnvironment, Add-AzEnvironment], [Clear-AzConfig, Clear-AzConfig], [Clear-AzContext, Clear-AzContext], [Clear-AzDefault, Clear-AzDefault]…}
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedFunctions : {}
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedVariables : {}
2023-10-17T21:14:40Z   [Information]   OUTPUT: NestedModules     : {Microsoft.Azure.PowerShell.Cmdlets.Accounts}
2023-10-17T21:14:40Z   [Information]   OUTPUT: 
2023-10-17T21:14:40Z   [Information]   OUTPUT: 
2023-10-17T21:14:40Z   [Information]   OUTPUT: Name              : Az.KeyVault
2023-10-17T21:14:40Z   [Information]   OUTPUT: Description       : Microsoft Azure PowerShell - Key Vault service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
2023-10-17T21:14:40Z   [Information]   OUTPUT:                     
2023-10-17T21:14:40Z   [Information]   OUTPUT:                     For more information on Key Vault, please visit the following: https://learn.microsoft.com/azure/key-vault/
2023-10-17T21:14:40Z   [Information]   OUTPUT: Guid              : cd188042-f215-4657-adfe-c17ae28cf730
2023-10-17T21:14:40Z   [Information]   OUTPUT: Version           : 4.9.3
2023-10-17T21:14:40Z   [Information]   OUTPUT: ModuleBase        : C:\home\data\ManagedDependencies\2310010044071717868.r\Az.KeyVault\4.9.3
2023-10-17T21:14:40Z   [Information]   OUTPUT: ModuleType        : Script
2023-10-17T21:14:40Z   [Information]   OUTPUT: PrivateData       : {PSData}
2023-10-17T21:14:40Z   [Information]   OUTPUT: AccessMode        : ReadWrite
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedAliases   : {[Set-AzKeyVaultCertificateAttribute, Set-AzKeyVaultCertificateAttribute], [Set-AzKeyVaultKey, Set-AzKeyVaultKey], [Set-AzKeyVaultKeyAttribute, Set-AzKeyVaultKeyAttribute], [Set-AzKeyVaultRoleDefinition, Set-AzKeyVaultRoleDefinition]…}
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedCmdlets   : {[Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificate], [Add-AzKeyVaultCertificateContact, Add-AzKeyVaultCertificateContact], [Add-AzKeyVaultKey, Add-AzKeyVaultKey], [Add-AzKeyVaultManagedStorageAccount, Add-AzKeyVaultManagedStorageAccount]…}
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedFunctions : {}
2023-10-17T21:14:40Z   [Information]   OUTPUT: ExportedVariables : {}
2023-10-17T21:14:40Z   [Information]   OUTPUT: NestedModules     : {Microsoft.Azure.PowerShell.Cmdlets.KeyVault, Az.KeyVault.Extension}
2023-10-17T21:14:40Z   [Information]   OUTPUT: 
2023-10-17T21:14:40Z   [Information]   INFORMATION: Function CacheDTLUsers starting! TIME: 10/17/2023 21:14:40
2023-10-17T21:14:40Z   [Verbose]   VERBOSE: The source code was already compiled and loaded.
2023-10-17T21:14:40Z   [Information]   OUTPUT: Path              : C:\home\data\ManagedDependencies\2310010044071717868.r\Az.KeyVault\4.9.3\Az.KeyVault.psm1
2023-10-17T21:14:40Z   [Information]   OUTPUT: 
2023-10-17T21:14:40Z   [Information]   OUTPUT: Environments : {[AzureChinaCloud, AzureChinaCloud], [AzureCloud, AzureCloud], [AzureUSGovernment, AzureUSGovernment]}
2023-10-17T21:14:40Z   [Information]   OUTPUT: Context      : Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext

Error output

no output
v-bafa commented 1 year ago

Added following command to force install the missing module, but still got same error. Install-Module -Name Microsoft.Identity.Client -RequiredVersion 4.49.1.0 -Force

v-bafa commented 1 year ago

Turned out this was due to https://github.com/Azure/azure-functions-powershell-worker/issues/1010

Francisco-Gamino commented 11 months ago

Hello @v-bafa -- Please refer to issue https://github.com/Azure/azure-functions-powershell-worker/issues/1010 in the PowerShell language worker. Closing this issue.