@@ -122,9 +122,9 @@ df.app.orchestration("helloSequence", function* (context) {
122122 const output = [];
123123 output .push (yield context .df .callActivity (helloActivityName, " Tokyo" ));
124124 output .push (yield context .df .callActivity (helloActivityName, " Seattle" ));
125- output .push (yield context .df .callActivity (helloActivityName, " Cairo " ));
125+ output .push (yield context .df .callActivity (helloActivityName, " London " ));
126126
127- // returns ["Hello Tokyo!", "Hello Seattle!", "Hello Cairo !"]
127+ // Return ["Hello Tokyo!", "Hello Seattle!", "Hello London !"].
128128 return output;
129129});
130130```
@@ -135,13 +135,21 @@ df.app.orchestration("helloSequence", function* (context) {
135135import azure.functions as func
136136import azure.durable_functions as df
137137
138+ # Create a FunctionApp instance.
139+ app = df.DFApp(http_auth_level = func.AuthLevel.ANONYMOUS )
140+
141+ # Orchestrator
142+ @app.orchestration_trigger (context_name = " context" )
138143def orchestrator_function (context : df.DurableOrchestrationContext):
139144 result1 = yield context.call_activity(' SayHello' , " Tokyo" )
140145 result2 = yield context.call_activity(' SayHello' , " Seattle" )
141146 result3 = yield context.call_activity(' SayHello' , " London" )
142147 return [result1, result2, result3]
143148
144- main = df.Orchestrator.create(orchestrator_function)
149+ # Activity
150+ @app.activity_trigger (input_name = " city" )
151+ def SayHello (city : str ):
152+ return f " Hello { city} "
145153```
146154
147155# [ PowerShell] ( #tab/powershell )
@@ -320,8 +328,11 @@ public static async Task CheckSiteAvailable(
320328 Uri url = context .GetInput <Uri >();
321329
322330 // Makes an HTTP GET request to the specified endpoint
323- DurableHttpResponse response =
324- await context .CallHttpAsync (HttpMethod .Get , url );
331+ DurableHttpResponse response = await context .CallHttpAsync (
332+ method : HttpMethod .Get ,
333+ uri : url ,
334+ content : null ,
335+ retryOptions : null );
325336
326337 if ((int )response .StatusCode == 400 )
327338 {
@@ -364,11 +375,14 @@ df.app.orchestration("checkSiteAvailable", function* (context) {
364375import azure.functions as func
365376import azure.durable_functions as df
366377
378+ app = df.DFApp(http_auth_level = func.AuthLevel.ANONYMOUS )
379+
380+ @app.orchestration_trigger (context_name = " context" )
367381def orchestrator_function (context : df.DurableOrchestrationContext):
368382 url = context.get_input()
369383 res = yield context.call_http(' GET' , url)
370- if res.status_code >= 400 :
371- # handing of error code goes here
384+ if res[ ' statusCode ' ] >= 400 :
385+ # Handle error codes.
372386```
373387
374388# [ PowerShell] ( #tab/powershell )
@@ -436,28 +450,28 @@ public static async Task<object> Mapper([ActivityTrigger] IDurableActivityContex
436450In .NET you can also use [ ValueTuple] ( /dotnet/csharp/tuples ) objects. The following sample is using new features of [ ValueTuple] ( /dotnet/csharp/tuples ) added with [ C# 7] ( /dotnet/csharp/whats-new/csharp-7#tuples ) :
437451
438452``` csharp
453+ public record CourseInfo (string Major , int UniversityYear );
454+
439455[Function (" GetCourseRecommendations" )]
440456public static async Task < object > RunOrchestrator (
441457 [OrchestrationTrigger ] TaskOrchestrationContext context , int universityYear )
442458{
443- string major = " ComputerScience" ;
444-
459+ CourseInfo courseInfo = new (" ComputerScience" , universityYear );
445460 object courseRecommendations = await context .CallActivityAsync <object >(
446- " CourseRecommendations" ,
447- (major , universityYear ));
461+ " CourseRecommendations" , courseInfo );
448462 return courseRecommendations ;
449463}
450464
451- [FunctionName (" CourseRecommendations" )]
452- public static async Task < object > Mapper (
453- [ActivityTrigger ] ( string Major , int UniversityYear ) studentInfo , FunctionContext executionContext )
465+ [Function (" CourseRecommendations" )]
466+ public static async Task < CourseInfo > Mapper (
467+ [ActivityTrigger ] CourseInfo studentInfo , FunctionContext executionContext )
454468{
455- // retrieve and return course recommendations by major and university year
469+ // Retrieve and return course recommendations by major and university year.
456470 return new
457471 {
458472 major = studentInfo .Major ,
459473 universityYear = studentInfo .UniversityYear ,
460- recommendedCourses = new []
474+ recommendedCourses = new []
461475 {
462476 " Introduction to .NET Programming" ,
463477 " Introduction to Linux" ,
@@ -485,7 +499,7 @@ module.exports = df.orchestrator(function*(context) {
485499});
486500```
487501
488- #### ` GetWeather ` Activity
502+ #### GetWeather activity
489503
490504``` javascript
491505module .exports = async function (context , location ) {
@@ -511,39 +525,37 @@ df.app.orchestration("getWeatherOrchestrator", function* (context) {
511525 // ...
512526});
513527
514- df .app .activity (getWeatherActivityName, async function (location ) {
515- const { city , state } = location; // destructure properties into variables
528+ df .app .activity (getWeatherActivityName, {
529+ handler: async (input ) => {
530+ const { city , state } = input; // Destructure properties into variables.
516531
517- // ...
532+ // ...
533+ }
518534});
519535```
520536
521537# [ Python] ( #tab/python )
522538
523- #### Orchestrator
524-
525539``` python
526540from collections import namedtuple
527541import azure.functions as func
528542import azure.durable_functions as df
529543
544+ # Create a FunctionApp instance.
545+ app = df.DFApp(http_auth_level = func.AuthLevel.ANONYMOUS )
546+
547+ # Orchestrator
548+ @app.orchestration_trigger (context_name = " context" )
530549def orchestrator_function (context : df.DurableOrchestrationContext):
531550 Location = namedtuple(' Location' , [' city' , ' state' ])
532551 location = Location(city = ' Seattle' , state = ' WA' )
533552
534553 weather = yield context.call_activity(" GetWeather" , location)
535-
536554 # ...
537555
538- ```
539- #### ` GetWeather ` Activity
540-
541- ``` python
542- from collections import namedtuple
543-
544- Location = namedtuple(' Location' , [' city' , ' state' ])
545-
546- def main (location : Location) -> str :
556+ # Activity
557+ @app.activity_trigger (input_name = " location" )
558+ def GetWeather (location ):
547559 city, state = location
548560 return f " Hello { city} , { state} ! "
549561```
0 commit comments