Azure / azure-functions-powershell-worker

PowerShell language worker for Azure Functions.
MIT License
206 stars 54 forks source link

Runtime fails to serialize json into hashtable for Durable activities #678

Open Francisco-Gamino opened 3 years ago

Francisco-Gamino commented 3 years ago

Repro steps

Provide the steps required to reproduce the problem:

  1. Create a powershell function with the following parameters image
  2. add an http trigger function with following code:
    using namespace System.Net
    param($Request, $TriggerMetadata)
    Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
    StatusCode = [HttpStatusCode]::OK
    Body = $Request.Body.GetType()
    })
  3. call the function with something like this:
    {"buildId":"id","sourceVersion":"version","scopes":["/subscriptions/fdbb6770-4977-44e9-9ee4-4cf0fcc1e6b3","/subscriptions/51c2c6a2-e6bd-492d-8a9d-0b02d6a325d8"],"certValue":"MIIDDjCCAfagAwIBAgIQFZlpQaNVZYpFor0BFa4zHzANBgkqhkiG9w0BAQUFADAaMRgwFgYDVQQDDA9zZWNvcHMtMDEwLWhhc2gwHhcNMjEwODEzMDc1MDQzWhcNMjEwODE0MTE1MDQzWjAaMRgwFgYDVQQDDA9zZWNvcHMtMDEwLWhhc2gwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaZTnBjT+szkqvd4FZS2hm+oww9jVZZAxwBNhLLhbq+N7y9EgtiWVsdlFgmoKH3hBaZca1631hqGafNdRGHZJu8DTmnyzgpHZLitzlmq3n4G65yC2kr4r88VSJvJieoCdSmOLjdmkl5Nm2Cedvp7EIs/u5VmjFw6dtYI1pgRmJAECYsxsKhABRnsUua7i2gAqEQs/TMgMoUXNnZ9y7aEDoLWgN7WlvMoOi2gFDFIxYhGoEQXD+EOexawbRMS2kfvAG2dE/fotSruSAf4zIabD0KjMVsAxHZiaAJ2LDEf/wVDWMzZ8CLq3R3XD807qE9RRbshZ+TefHZhBO7j/y00OBAgMBAAGjUDBOMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEwHQYDVR0OBBYEFHy8F1cMI0ajtKr5+aizJNeBLatXMA0GCSqGSIb3DQEBBQUAA4IBAQCvPpBv8Uz2loVd/VhcUQNuCcam14vl5AS/mW72A37MVqi5BOjDLfUFzkrAIUiPRZSwuy+4JQrwRCdIZidWpcQXILwGA2FwXE7P4K4TNAKru2EUgbHL1TMUM73+/Epn2Pj5VtA5zrYbmToNYkDp3juYPieGV//9A112rStFc1mAl+OziQb0YMv2X255ECOe+eliSODxzupzUs9VEHsYPHWJLPnufVsGrGRSEmpbu3dy+YsTbB6dtLZE2AqdTDPhbKJBvLb78FgGiDide4gcp4MhC1Rm9k2NYpNf/EDcPHcWRGvSZ+49JsZup9CWec/7EbZ5MrGJxHt2fpw19khAGyMw"}

Expected behavior

returns System.Collections.Hashtable

Actual behavior

returns System.String

Known workarounds

forcefully cast to an object with $Request.Body | ConvertFrom-Json

Related information

https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell?tabs=portal#request-object

Francisco-Gamino commented 3 years ago

Hello @4c74356b41 -- Could you please explain your scenario in which you are trying to pass data between Durable activities and you are facing the deserialization issue? Thanks.

4c74356b41 commented 3 years ago

orchestrator function

$cleanerReference = @{
    runId         = $ctxObj.runId
    source        = "orchestrator"
    applicationId = $ctxObj.applicationId # string
    assignments   = $ctxObj.assignments # array of strings
}

Invoke-DurableActivity `
    -Input $cleanerReference `
    -FunctionName cleaner | Out-Null

cleaner function:

param( $cleanerReference )
Remove-AzADApplication -ApplicationId $cleanerReference.applicationId -Force
$body = @{
    runId         = $cleanerReference.runId
    applicationId = $cleanerReference.applicationId
    source        = "cleaner"
}

# array gets passed as string with spaces -..-
# https://github.com/Azure/azure-functions-powershell-worker/issues/669
$cleanerReference.assignments.split().foreach{
     xxx
}
lilyjma commented 8 months ago

@davidmrdavid - is this something fixed in the standalone SDK by any chance?

lilyjma commented 8 months ago

Hi @4c74356b41, 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!

4c74356b41 commented 8 months ago

@lilyjma hey, sorry, i'm not on that project anymore, so cant speak on their behalf and this development was productionized in ~ october 2021. not sure if its still working, but it was working fine