Skip to content

Commit

Permalink
Updated samples and README to 1.0.0 release API. (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
kashimiz authored and cgillum committed Oct 23, 2018
1 parent ba0f259 commit 68d87db
Show file tree
Hide file tree
Showing 20 changed files with 1,102 additions and 366 deletions.
6 changes: 2 additions & 4 deletions README.md
Expand Up @@ -55,10 +55,8 @@ The [Durable Functions samples](https://docs.microsoft.com/en-us/azure/azure-fun

* [Function Chaining - Hello Sequence](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-sequence)
* [Fan-out/Fan-in - Cloud Backup](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-cloud-backup)
* [Monitors - Weather Watcher](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-monitor) \*
* [Human Interaction & Timeouts - Phone Verification](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-phone-verification) \*

\* <sub>Currently available in C# only</sub>
* [Monitors - Weather Watcher](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-monitor)
* [Human Interaction & Timeouts - Phone Verification](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-phone-verification)

```javascript
const df = require("durable-functions");
Expand Down
6 changes: 3 additions & 3 deletions test/sample/E2_BackupSiteContent/index.js
@@ -1,17 +1,17 @@
const df = require("durable-functions");

module.exports = df(function*(context){
module.exports = df.orchestrator(function*(context){
const rootDirectory = context.df.getInput();
if (!rootDirectory) {
throw new Error("A directory path is required as an input.");
}

const files = yield context.df.callActivityAsync("E2_GetFileList", rootDirectory);
const files = yield context.df.callActivity("E2_GetFileList", rootDirectory);

// Backup Files and save Promises into array
const tasks = [];
for (const file of files) {
tasks.push(context.df.callActivityAsync("E2_CopyFileToBlob", file));
tasks.push(context.df.callActivity("E2_CopyFileToBlob", file));
}

// wait for all the Backup Files Activities to complete, sum total bytes
Expand Down
6 changes: 3 additions & 3 deletions test/sample/E3_Monitor/index.js
@@ -1,7 +1,7 @@
const df = require("durable-functions");
const moment = require('moment');

module.exports = df(function*(context) {
module.exports = df.orchestrator(function*(context) {
const input = context.df.getInput();
context.log("Received monitor request. location: " + (input ? input.location : undefined)
+ ". phone: " + (input ? input.phone : undefined) + ".");
Expand All @@ -16,14 +16,14 @@ module.exports = df(function*(context) {
// Check the weather
context.log("Checking current weather conditions for " + input.location.city + ", "
+ input.location.state + " at " + context.df.currentUtcDateTime + ".");
const isClear = yield context.df.callActivityAsync("E3_GetIsClear", input.location);
const isClear = yield context.df.callActivity("E3_GetIsClear", input.location);

if (isClear) {
// It's not raining! Or snowing. Or misting. Tell our user to take advantage of it.
context.log("Detected clear weather for " + input.location.city + ", "
+ input.location.state + ". Notifying " + input.phone + ".");

yield context.df.callActivityAsync("E3_SendGoodWeatherAlert", input.phone);
yield context.df.callActivity("E3_SendGoodWeatherAlert", input.phone);
break;
} else {
// Wait for the next checkpoint
Expand Down
4 changes: 2 additions & 2 deletions test/sample/E4_SmsPhoneVerification/index.js
@@ -1,13 +1,13 @@
const df = require("durable-functions");
const moment = require('moment');

module.exports = df(function*(context) {
module.exports = df.orchestrator(function*(context) {
const phoneNumber = context.df.getInput();
if (!phoneNumber) {
throw "A phone number input is required.";
}

const challengeCode = yield context.df.callActivityAsync("E4_SendSmsChallenge", phoneNumber);
const challengeCode = yield context.df.callActivity("E4_SendSmsChallenge", phoneNumber);

// The user has 90 seconds to respond with the code they received in the SMS message.
const expiration = moment.utc(context.df.currentUtcDateTime).add(90, 's');
Expand Down
10 changes: 0 additions & 10 deletions test/sample/F1/function.json

This file was deleted.

7 changes: 0 additions & 7 deletions test/sample/F1/run.csx

This file was deleted.

10 changes: 0 additions & 10 deletions test/sample/F2/function.json

This file was deleted.

7 changes: 0 additions & 7 deletions test/sample/F2/run.csx

This file was deleted.

23 changes: 0 additions & 23 deletions test/sample/HttpStart/function.json

This file was deleted.

22 changes: 0 additions & 22 deletions test/sample/HttpStart/run.csx

This file was deleted.

10 changes: 0 additions & 10 deletions test/sample/any-a-or-b/function.json

This file was deleted.

12 changes: 0 additions & 12 deletions test/sample/any-a-or-b/index.js

This file was deleted.

6 changes: 3 additions & 3 deletions test/sample/cancel-timer/index.js
@@ -1,11 +1,11 @@
const df = require("../../../lib/");
const df = require("durable-functions");
const moment = require('moment');

module.exports = df(function*(context){
module.exports = df.orchestrator(function*(context){
const expiration = moment.utc(context.df.currentUtcDateTime).add(2, 'm');
const timeoutTask = context.df.createTimer(expiration.toDate());

const hello = yield context.df.callActivityAsync("E1_SayHello", "from the other side");
const hello = yield context.df.callActivity("E1_SayHello", "from the other side");

if (!timeoutTask.isCompleted) {
timeoutTask.cancel();
Expand Down
5 changes: 3 additions & 2 deletions test/sample/extensions.csproj
Expand Up @@ -5,8 +5,9 @@
<DefaultItemExcludes>**</DefaultItemExcludes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.5.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Twilio" Version="3.0.0-beta7" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.6.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Twilio" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.0-beta3" />
</ItemGroup>
</Project>
21 changes: 13 additions & 8 deletions test/sample/host.json
@@ -1,13 +1,18 @@
{
"http": {
"routePrefix": ""
},
"applicationInsights": {
"sampling": {
"isEnabled": false
"version": "2.0",
"extensions": {
"http": {
"routePrefix": ""
},
"durableTask": {
"HubName": "SampleHubJs"
}
},
"durableTask": {
"HubName": "SampleHubJs"
"logging": {
"applicationInsights": {
"sampling": {
"isEnabled": false
}
}
}
}

0 comments on commit 68d87db

Please sign in to comment.