Skip to content

Write-Host, Write-Verbose, Write-Error etc. invoked from profile.ps1 cause error 500 #337

@AnatoliB

Description

@AnatoliB

When Write-Host, Write-Verbose, or Write-Error are invoked from profile.ps1:

  • Function invocation requests get error 500 response.
  • The function code is not executed.
  • The messages passed to Write-Host, Write-Verbose, or Write-Error are not logged anywhere.

Instead, the following internal exception is logged:

Result: Failure
Exception: Value cannot be null.
Parameter name: value
Stack:    at Google.Protobuf.ProtoPreconditions.CheckNotNull[T](T value, String name)
   at Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage.set_RequestId(String value) in C:\projects\azure-functions-powershell-worker\src\Messaging\protobuf\FunctionRpc.cs:line 309
   at Microsoft.Azure.Functions.PowerShellWorker.Utility.RpcLogger.Log(Boolean isUserOnlyLog, Level logLevel, String message, Exception exception) in C:\projects\azure-functions-powershell-worker\src\Logging\RpcLogger.cs:line 45
   at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellManager.InvokeProfile(String profilePath) in C:\projects\azure-functions-powershell-worker\src\PowerShell\PowerShellManager.cs:line 181
   at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellManager.Initialize() in C:\projects\azure-functions-powershell-worker\src\PowerShell\PowerShellManager.cs:line 106
   at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellManagerPool.CheckoutIdleWorker(StreamingMessage request, AzFunctionInfo functionInfo) in C:\projects\azure-functions-powershell-worker\src\PowerShell\PowerShellManagerPool.cs:line 99
   at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessInvocationRequest(StreamingMessage request) in C:\projects\azure-functions-powershell-worker\src\RequestProcessor.cs:line 242
2019-09-24T19:44:48.901 [Information] Executing 'Functions.HttpTrigger' (Reason='This function was programmatically called via the host APIs.', Id=dec08344-1330-42d2-bae7-fbaead36a2b9)
2019-09-24T19:44:49.978 [Error] Executed 'Functions.HttpTrigger' (Failed, Id=dec08344-1330-42d2-bae7-fbaead36a2b9)

Note: Write-Output does not cause this error, but the data passed to Write-Output also does not seem to be logged anywhere.

This experience is inconsistent with what regular PS console users observe (the output produced by these cmdlets is displayed even when they are invoked from profile.ps1) and makes debugging and troubleshooting difficult.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions