Same thing was happening to me. For some odd reason, once I added a "Write-Output" on my activity function the error went away. Not sure if you want to try using Write-Output instead of Write-Information
Error while trying to pass POST request into chain of activity functions in Azure Functions in PowerShell. What am I doing wrong?
I am getting input from a POST request into my orchestrator function and passing it into my activity functions. But, after my first activity function, each of the activity functions throw an error mentioning the input cannot be null:
ERROR: Value cannot be null. (Parameter 'input')
Exception :
Type : System.ArgumentNullException
Message : Value cannot be null. (Parameter 'input')
ParamName : input
TargetSite :
Name : ConvertFromJson
DeclaringType : Microsoft.PowerShell.Commands.JsonObject
MemberType : Method
Module : Microsoft.PowerShell.Commands.Utility.dll
StackTrace :
at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, Boolean returnHashtable, Nullable`1 maxDepth, ErrorRecord& error)
at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, Boolean returnHashtable, ErrorRecord& error)
at Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.ConvertFromJson(String json) in /mnt/vss/_work/1/s/src/Utility/TypeExtensions.cs:line 118
at Microsoft.Azure.Functions.PowerShellWorker.Durable.DurableTaskHandler.GetEventResult(HistoryEvent historyEvent) in /mnt/vss/_work/1/s/src/Durable/DurableTaskHandler.cs:line 220
at Microsoft.Azure.Functions.PowerShellWorker.Durable.DurableTaskHandler.StopAndInitiateDurableTaskOrReplay(DurableTask task, OrchestrationContext context, Boolean noWait, Action`1 output, Action`1 onFailure, RetryOptions retryOptions) in /mnt/vss/_work/1/s/src/Durable/DurableTaskHandler.cs:line 55
at Microsoft.Azure.Functions.PowerShellWorker.Durable.Commands.InvokeDurableActivityCommand.EndProcessing() in /mnt/vss/_work/1/s/src/Durable/Commands/InvokeDurableActivityCommand.cs:line 51
at System.Management.Automation.Cmdlet.DoEndProcessing()
at System.Management.Automation.CommandProcessorBase.Complete()
Source : Microsoft.PowerShell.Commands.Utility
HResult : -2147467261
CategoryInfo : NotSpecified: (:) [Invoke-DurableActivity], ArgumentNullException
FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Azure.Functions.PowerShellWorker.Durable.Commands.InvokeDurableActivityCommand
InvocationInfo :
MyCommand : Invoke-DurableActivity
ScriptLineNumber : 5
OffsetInLine : 12
HistoryId : 1
ScriptName : C:\home\site\wwwroot\InstallOrchestrator\run.ps1
Line : $output += Invoke-DurableActivity -FunctionName 'CreateSiteCollection' -Input $Context.Input
PositionMessage : At C:\home\site\wwwroot\InstallOrchestrator\run.ps1:5 char:12
+ $output += Invoke-DurableActivity -FunctionName 'CreateSiteCollection …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\home\site\wwwroot\InstallOrchestrator
PSCommandPath : C:\home\site\wwwroot\InstallOrchestrator\run.ps1
InvocationName : Invoke-DurableActivity
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\InstallOrchestrator\run.ps1: line 5
However, even after this error, the activity functions seem to be able to retrieve data from the input! I know this because I am assigning variables based on the input from the http request in the activity functions, and they are successfully getting that data. Simple example - at the beginning of an activity function in PowerShell:
param($install)
$SiteUrl = $install.SiteUri
$SiteTitle = $install.SiteTitle
#returns proper info in log stream
Write-Information "SiteUrl: $($SiteUrl)"
All of these variables are successfully assigned but I keep getting the error above in the log stream. The POST body sent is similar to the following (an array of JSON objects):
[
{
"SiteUrl" : "https://contoso.sharepoint.com/sites/test",
"SiteTitle" : "TitleOfSite",
}
]
Does anyone know what is going on? Can I only use the http request input in the first activity function? I'm not finding enough info in the docs specifically for PowerShell. How am I supposed to pass the same input data into multiple activity functions in PowerShell?
The use case is for configuring SharePoint Online sites with PowerShell using the PnP PowerShell module.