Azure / azure-functions-powershell-worker

PowerShell language worker for Azure Functions.
MIT License
203 stars 52 forks source link

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

Open PawelKaczanowski7N opened 2 years ago

PawelKaczanowski7N commented 2 years ago

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] } !
kwill-MSFT commented 2 years ago

@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.

PawelKaczanowski7N commented 2 years ago

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

davidmrdavid commented 2 years ago

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 commented 1 year ago

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!

lilyjma commented 6 months ago

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!