@@ -500,15 +500,16 @@ It isn't possible to pass multiple parameters to an activity function directly.
500500<details >
501501<summary ><b >Isolated worker model</b ></summary >
502502
503- In .NET, you can use record types or [ ValueTuple ] ( /dotnet/csharp/language-reference/builtin-types/value-tuples ) objects to pass multiple parameters.
503+ In .NET, use a serializable composite type, such as a record, to pass multiple parameters.
504504
505505``` csharp
506506public record CourseInfo (string Major , int UniversityYear );
507507
508508[Function (" GetCourseRecommendations" )]
509509public static async Task < object > RunOrchestrator (
510- [OrchestrationTrigger ] TaskOrchestrationContext context , int universityYear )
510+ [OrchestrationTrigger ] TaskOrchestrationContext context )
511511{
512+ int universityYear = context .GetInput <int >();
512513 CourseInfo courseInfo = new (" ComputerScience" , universityYear );
513514 object courseRecommendations = await context .CallActivityAsync <object >(
514515 " CourseRecommendations" , courseInfo );
@@ -523,19 +524,28 @@ public static async Task<object> RunOrchestrator(
523524<details >
524525<summary ><b >In-process model</b ></summary >
525526
526- In .NET, you can also use [ ValueTuple ] ( /dotnet/csharp/language-reference/builtin-types/value-tuples ) objects to pass multiple parameters. The following sample uses [ ValueTuple ] ( /dotnet/csharp/language-reference/builtin-types/value-tuples ) features added with [ C# 7 ] ( /dotnet/csharp/whats-new/csharp-version-history#c-version-70 ) :
527+ In .NET, use a serializable composite type to pass multiple parameters. The following sample uses a simple class :
527528
528529``` csharp
530+ public class CourseInfo
531+ {
532+ public string Major { get ; set ; }
533+ public int UniversityYear { get ; set ; }
534+ }
535+
529536[FunctionName (" GetCourseRecommendations" )]
530537public static async Task < object > RunOrchestrator (
531538 [OrchestrationTrigger ] IDurableOrchestrationContext context )
532539{
533- string major = " ComputerScience" ;
534- int universityYear = context .GetInput <int >();
540+ var input = new CourseInfo
541+ {
542+ Major = " ComputerScience" ,
543+ UniversityYear = context .GetInput <int >()
544+ };
535545
536546 object courseRecommendations = await context .CallActivityAsync <object >(
537547 " CourseRecommendations" ,
538- ( major , universityYear ) );
548+ input );
539549 return courseRecommendations ;
540550}
541551```
@@ -568,23 +578,22 @@ df.app.activity("getWeather", {
568578# [ Python] ( #tab/python )
569579
570580``` python
571- from collections import namedtuple
572581import azure.functions as func
573582import azure.durable_functions as df
574583
575584app = df.DFApp(http_auth_level = func.AuthLevel.ANONYMOUS )
576585
577586@app.orchestration_trigger (context_name = " context" )
578587def orchestrator_function (context : df.DurableOrchestrationContext):
579- Location = namedtuple(' Location' , [' city' , ' state' ])
580- location = Location(city = ' Seattle' , state = ' WA' )
588+ location = {' city' : ' Seattle' , ' state' : ' WA' }
581589
582590 weather = yield context.call_activity(" GetWeather" , location)
583591 # ...
584592
585593@app.activity_trigger (input_name = " location" )
586594def GetWeather (location ):
587- city, state = location
595+ city = location[' city' ]
596+ state = location[' state' ]
588597 return f " Hello { city} , { state} ! "
589598```
590599
@@ -598,7 +607,7 @@ $location = @{
598607 State = 'WA'
599608}
600609
601- Invoke-ActivityFunction -FunctionName 'GetWeather' -Input $location
610+ Invoke-DurableActivity -FunctionName 'GetWeather' -Input $location
602611
603612# ...
604613```
0 commit comments