azure-functions-powershell-worker icon indicating copy to clipboard operation
azure-functions-powershell-worker copied to clipboard

Invoke-DurableActivity -Input takes only objects nested max 1 level

Open PawelKaczanowski7N opened this issue 3 years ago • 5 comments

Orchestation function:

$t1 = @{a=1;b=2}
$t2 = @{t1=$t1;c=3}
Invoke-DurableActivity -FunctionName 'Hello1' -input $t2

Hello1 function:

param($name) 
"Hello $($name | ConvertTo-Json -Depth 100) !"

Output:

OUTPUT: Hello {
[2022-02-08T14:30:20.871Z]   "t1": "System.Collections.Hashtable",
[2022-02-08T14:30:20.872Z]   "c": 3
[2022-02-08T14:30:20.873Z] } !

PawelKaczanowski7N avatar Feb 08 '22 14:02 PawelKaczanowski7N

@PawelKaczanowski7N see https://github.com/Azure/azure-functions-durable-extension/issues/1922. Specifically you will want to serialize your object to JSON before sending it to the activity function:

Invoke-DurableActivity -FunctionName 'Test2' -Input ($result | ConvertTo-Json -Depth 5)

@davidmrdavid as the owner of that other issue where docs are supposed to be updated.

kwill-MSFT avatar Feb 22 '22 07:02 kwill-MSFT

It's a dirty workaround but it will work in most cases(my also), side effect is that you loose objects type as everything is converted to hashtables and arrays.

Thank you

PawelKaczanowski7N avatar Feb 22 '22 08:02 PawelKaczanowski7N

Thanks @PawelKaczanowski7N and @kwill-MSFT.

This is a tricky behavior to fix because it constitutes a breaking change, but we're aware of it and I've already included the fix in the code for the next major release of the Durable Functions for PowerShell SDK. I'm looking to release that as soon as possible, most likely in the next few months (since it's a breaking change release, it requires time). I should be able to provide more updates on this soon :)

davidmrdavid avatar Mar 18 '22 17:03 davidmrdavid

Hey @PawelKaczanowski7N, @kwill-MSFT:

The release took longer than expected on our end, my apologies for that, but this new SDK has finally been announced here. This new SDK allows us to version breaking changes properly as it's published as a standalone package in the PowerShell gallery, which means we were finally able to deal with this issue as well as several others. Just wanted to notify you all in case you were interested in giving it a try. Please note that this SDK package is currently in public preview, but the plan is to GA it fairly quickly, in time for PowerShell 7.4 support in Azure Functions. That's all, thanks!

davidmrdavid avatar Jun 12 '23 22:06 davidmrdavid

Hi @PawelKaczanowski7N - thank you for using Durable Functions! I'm a PM working on DF and would love to learn about your experience. If your time allows, please grab a meeting with us here. Understanding the problems you're trying to solve will help us target future development. Thanks!

lilyjma avatar Mar 04 '24 16:03 lilyjma