Skip to content

Commit 4d63ea2

Browse files
committed
Revert code edits
1 parent 8ffc015 commit 4d63ea2

1 file changed

Lines changed: 27 additions & 36 deletions

File tree

articles/azure-functions/durable/durable-functions-orchestrations.md

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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, "London"));
125+
output.push(yield context.df.callActivity(helloActivityName, "Cairo"));
126126

127-
// Return ["Hello Tokyo!", "Hello Seattle!", "Hello London!"].
127+
// Return ["Hello Tokyo!", "Hello Seattle!", "Hello Cairo!"].
128128
return output;
129129
});
130130
```
@@ -135,21 +135,13 @@ df.app.orchestration("helloSequence", function* (context) {
135135
import azure.functions as func
136136
import 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")
143138
def orchestrator_function(context: df.DurableOrchestrationContext):
144139
result1 = yield context.call_activity('SayHello', "Tokyo")
145140
result2 = yield context.call_activity('SayHello', "Seattle")
146141
result3 = yield context.call_activity('SayHello', "London")
147142
return [result1, result2, result3]
148143

149-
# Activity
150-
@app.activity_trigger(input_name="city")
151-
def SayHello(city: str):
152-
return f"Hello {city}"
144+
main = df.Orchestrator.create(orchestrator_function)
153145
```
154146

155147
# [PowerShell](#tab/powershell)
@@ -328,11 +320,8 @@ public static async Task CheckSiteAvailable(
328320
Uri url = context.GetInput<Uri>();
329321

330322
// Make an HTTP GET request to the specified endpoint.
331-
DurableHttpResponse response = await context.CallHttpAsync(
332-
method: HttpMethod.Get,
333-
uri: url,
334-
content: null,
335-
retryOptions: null);
323+
DurableHttpResponse response =
324+
await context.CallHttpAsync(HttpMethod.Get, url);
336325

337326
if ((int)response.StatusCode == 400)
338327
{
@@ -381,7 +370,7 @@ app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
381370
def orchestrator_function(context: df.DurableOrchestrationContext):
382371
url = context.get_input()
383372
res = yield context.call_http('GET', url)
384-
if res['statusCode'] >= 400:
373+
if res.status_code >= 400:
385374
# Handle error codes.
386375
```
387376

@@ -449,28 +438,28 @@ public static async Task<object> Mapper([ActivityTrigger] IDurableActivityContex
449438

450439
```csharp
451440

452-
public record CourseInfo(string Major, int UniversityYear);
453-
454441
[Function("GetCourseRecommendations")]
455442
public static async Task<object> RunOrchestrator(
456443
[OrchestrationTrigger] TaskOrchestrationContext context, int universityYear)
457444
{
458-
CourseInfo courseInfo = new("ComputerScience", universityYear);
445+
string major = "ComputerScience";
446+
459447
object courseRecommendations = await context.CallActivityAsync<object>(
460-
"CourseRecommendations", courseInfo);
448+
"CourseRecommendations",
449+
(major, universityYear));
461450
return courseRecommendations;
462451
}
463452

464-
[Function("CourseRecommendations")]
465-
public static async Task<CourseInfo> Mapper(
466-
[ActivityTrigger] CourseInfo studentInfo, FunctionContext executionContext)
453+
[FunctionName("CourseRecommendations")]
454+
public static async Task<object> Mapper(
455+
[ActivityTrigger] (string Major, int UniversityYear) studentInfo, FunctionContext executionContext)
467456
{
468457
// Retrieve and return course recommendations by major and university year.
469458
return new
470459
{
471460
major = studentInfo.Major,
472461
universityYear = studentInfo.UniversityYear,
473-
recommendedCourses = new[]
462+
recommendedCourses = new []
474463
{
475464
"Introduction to .NET Programming",
476465
"Introduction to Linux",
@@ -524,9 +513,8 @@ df.app.orchestration("getWeatherOrchestrator", function* (context) {
524513
// ...
525514
});
526515

527-
df.app.activity(getWeatherActivityName, {
528-
handler: async (input) => {
529-
const { city, state } = input; // Destructure properties into variables.
516+
df.app.activity(getWeatherActivityName, async function (location) {
517+
const { city, state } = location; // Destructure properties into variables.
530518

531519
// ...
532520
}
@@ -535,26 +523,29 @@ df.app.activity(getWeatherActivityName, {
535523

536524
# [Python](#tab/python)
537525

526+
#### Orchestrator
527+
538528
```python
539529
from collections import namedtuple
540530
import azure.functions as func
541531
import azure.durable_functions as df
542532

543-
# Create a FunctionApp instance.
544-
app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
545-
546-
# Orchestrator
547-
@app.orchestration_trigger(context_name="context")
548533
def orchestrator_function(context: df.DurableOrchestrationContext):
549534
Location = namedtuple('Location', ['city', 'state'])
550535
location = Location(city='Seattle', state= 'WA')
551536

552537
weather = yield context.call_activity("GetWeather", location)
553538
# ...
539+
```
540+
541+
#### GetWeather activity
542+
543+
```python
544+
from collections import namedtuple
545+
546+
Location = namedtuple('Location', ['city', 'state'])
554547

555-
# Activity
556-
@app.activity_trigger(input_name="location")
557-
def GetWeather(location):
548+
def main(location: Location) -> str:
558549
city, state = location
559550
return f"Hello {city}, {state}!"
560551
```

0 commit comments

Comments
 (0)