Reputation: 2503
I have Azure Durable Function. It is mostly based on: https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-python-vscode
I'm trying to migrate reqular HTTP Trigger as Durable Function?
I have modified code to accept json in HTTP Start and Orchestrator Functions. However Activity Function cannot take in json. How to modify HelloActivity to accept json? Following line seems to cause issue.
def main(datajson: str) -> str:
HelloOrchestrator:
import logging
import json
import azure.functions as func
import azure.durable_functions as df
def orchestrator_function(context: df.DurableOrchestrationContext):
# Take the json data from the DurableOrchestrationContext, which was passed during the invocation
data = context._input
data = json.loads(data)
logging.info(f"Orchestrator: Input is: {data}")
result1 = yield context.call_activity('HelloActivity', data)
#result1 = yield context.call_activity('HelloActivity', "ThisWouldWork")
return [result1]
main = df.Orchestrator.create(orchestrator_function)
HelloActivity
import logging
def main(datajson: str) -> str:
logging.info(f"Activity datajson :" + datajson)
return f"Hello world"
Error:
Function 'HelloOrchestrator (Orchestrator)' failed with an error. Reason: Message:
Activity function 'HelloActivity' failed: TypeError: can only concatenate str (not
"dict") to str
{"$type":"System.Exception,
System.Private.CoreLib","ClassName":"System.Exception","Message":" TypeError: can only
concatenate str (not \"dict\") to str","Data":null,"InnerException":{"$type":"Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException,
Upvotes: 1
Views: 1137
Reputation: 4893
Thank you @John Hanley , For your suggestion Posting it as an answer to help other community .
Reason: Message: Activity function 'HelloActivity' failed: TypeError: can only concatenate str (not "dict") to str ```
For the above error :
" Your error is with this line logging. info(f"Orchestrator: Input is: {data}")
,
Pass the original string (context._input)
and not the dictionary object ."
For more information please refer this Blog .
Upvotes: 2