Open v-bafa opened 1 year ago
Thanks for reporting the issue. I'll follow up with it.
Thank you, @isra-fel
I tried to update the command to follows in function script but got following errors when trying to read KeyVault.
if ((Get-AzContext).Count -eq 0) {
Connect-AzAccount -Identity -AccountId $ENV:AZURE_CLIENT_ID
}
ERROR: Run Connect-AzAccount to login.
Exception : Type : System.Management.Automation.PSInvalidOperationException ErrorRecord : Exception : Type : System.Management.Automation.ParentContainsErrorRecordException Message : Run Connect-AzAccount to login. HResult : -2146233087 CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException FullyQualifiedErrorId : InvalidOperation TargetSite : Name : get_DefaultContext DeclaringType : Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet MemberType : Method Module : Microsoft.Azure.PowerShell.Clients.ResourceManager.dll Message : Run Connect-AzAccount to login. Source : Microsoft.Azure.PowerShell.Clients.ResourceManager HResult : -2146233079 StackTrace : at Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet.get_DefaultContext() at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultCmdletBase.get_DataServiceClient() at Microsoft.Azure.Commands.KeyVault.GetAzureKeyVaultSecret.ExecuteCmdlet() at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c3`1.
b 3_0(T c) at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor) at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet) at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord() CategoryInfo : CloseError: (:) [Get-AzKeyVaultSecret], PSInvalidOperationException FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.GetAzureKeyVaultSecret InvocationInfo : MyCommand : Get-AzKeyVaultSecret ScriptLineNumber : 40 OffsetInLine : 26 HistoryId : 1 ScriptName : C:\home\site\wwwroot\Modules\xxxx\xxxx.psm1 Line : $azureFunctionKey = (Get-AzKeyVaultsecret -VaultName $ENV:ICM_AZFUNCTIONKEY_KV -Name $Env:ICM_AZFUNCTIONKEY_SECRET).SecretValue | ConvertFrom-SecureString -AsPlainTextPositionMessage : At C:\home\site\wwwroot\Modules\xxxx\xxxx.psm1:40 char:26 + … ctionKey = (Get-AzKeyVaultsecret -VaultName $ENV:ICM_AZFUNCTIONKEY_KV … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PSScriptRoot : C:\home\site\wwwroot\Modules\xxxx PSCommandPath : C:\home\site\wwwroot\Modules\xxxx\xxxx.psm1 InvocationName : Get-AzKeyVaultsecret CommandOrigin : Internal
ScriptStackTrace : at Write-IcMIncident, C:\home\site\wwwroot\Modules\xxxx\xxxx.psm1: line 40 at Invoke-RemoteScript, C:\home\site\wwwroot\Modules\xxx\xxx.psm1: line 119 at
, C:\home\site\wwwroot\yyyyy\run.ps1: line 53 PipelineIterationInfo :
This is the authentication commands in profile.ps1.
if ($env:MSI_SECRET) {
Connect-AzAccount -Identity -AccountId $ENV:AZURE_CLIENT_ID
}
I added the command to each function as it randomly throws the following errors and failed to read KeyVault.
However, with adding Connect-AzAccount -Identity -AccountId $ENV:AZURE_CLIENT_ID
directly, it throws the errors The given key 'WriteWarning-System.EventHandler
1` in the issue...after adding the checking line, it failed to read KeyVault randomly again...
We have 16 timer trigger functions within one function app running every 5/10/15 minutes, and 3 queue trigger functions might run at same time. Follows are related configurations. FUNCTIONS_WORKER_PROCESS_COUNT = 10 FUNCTIONS_WORKER_RUNTIME = powershell FUNCTIONS_EXTENSION_VERSION = ~4
I have same issue here. Looks it randomly showed up.
EXCEPTION: Activity function 'DeployActivity' failed: The given key 'WriteInformation-System.EventHandler
1[[Microsoft.Azure.Commands.Common.Authentication.Abstractions.StreamEventArgs, Microsoft.Azure.PowerShell.Authentication.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' was not present in the dictionary.
Exception : Type : Microsoft.Azure.Functions.PowerShellWorker.Durable.ActivityFailureException Message : Activity function 'DeployActivity' failed: The given key 'WriteInformation-System.EventHandler`1[[Microsoft.Azure.Commands.Common.Authentication.Abstractions.StreamEventArgs, Microsoft.Azure.PowerShell.Authentication.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' was not present in the dictionary. HResult : -2146233088 CategoryInfo : NotSpecified: (:) [Invoke-DurableActivity], ActivityFailureException FullyQualifiedErrorId : Functions.Durable.ActivityFailure,Microsoft.Azure.Functions.PowerShellWorker.Durable.Commands.InvokeDurableActivityCommand InvocationInfo : MyCommand : Invoke-DurableActivity ScriptLineNumber : 13 OffsetInLine : 16 HistoryId : 1 ScriptName : /home/site/wwwroot/DeployOrchestrator/run.ps1 Line : $output += Invoke-DurableActivity -FunctionName 'DeployActivity' -Input $Context.Input
Statement : Invoke-DurableActivity -FunctionName 'DeployActivity' -Input $Context.Input
PositionMessage : At /home/site/wwwroot/DeployOrchestrator/run.ps1:13 char:16
+ … $output += Invoke-DurableActivity -FunctionName 'DeployActivity' -In …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot/DeployOrchestrator
PSCommandPath : /home/site/wwwroot/DeployOrchestrator/run.ps1
InvocationName : Invoke-DurableActivity
CommandOrigin : Internal
ScriptStackTrace : at
Description
I have following command for connect Azure with user assigned managed identity in Azure Functions (we have 18 functions running at same time). But got exceptions in some invocations.
Connect-AzAccount -Identity -AccountId $ENV:AZURE_CLIENT_ID
Script or Debug output
Environment data
No response
Module versions
No response
Error output
No response