@@ -712,13 +712,11 @@ public static async Task Run(
712
712
[DurableClient ] IDurableOrchestrationClient client ,
713
713
[QueueTrigger (" suspend-resume-queue" )] string instanceId )
714
714
{
715
+ // To suspend an orchestration
715
716
string suspendReason = " Need to pause workflow" ;
716
717
await client .SuspendAsync (instanceId , suspendReason );
717
718
718
- // Wait for 30 seconds to ensure that the orchestrator state is updated to suspended.
719
- DateTime dueTime = context .CurrentUtcDateTime .AddSeconds (30 );
720
- await context .CreateTimer (dueTime , CancellationToken .None );
721
-
719
+ // To resume an orchestration
722
720
string resumeReason = " Continue workflow" ;
723
721
await client .ResumeAsync (instanceId , resumeReason );
724
722
}
@@ -732,13 +730,11 @@ const df = require("durable-functions");
732
730
module .exports = async function (context , instanceId ) {
733
731
const client = df .getClient (context);
734
732
733
+ // To suspend an orchestration
735
734
const suspendReason = " Need to pause workflow" ;
736
735
await client .suspend (instanceId, suspendReason);
737
736
738
- // Wait for 30 seconds to ensure that the orchestrator state is updated to suspended.
739
- const deadline = DateTime .fromJSDate (context .df .currentUtcDateTime , {zone: ' utc' }).plus ({ seconds: 30 });
740
- yield context .df .createTimer (deadline .toJSDate ());
741
-
737
+ // To resume an orchestration
742
738
const resumeReason = " Continue workflow" ;
743
739
await client .resume (instanceId, resumeReason);
744
740
};
@@ -754,13 +750,11 @@ from datetime import timedelta
754
750
async def main (req : func.HttpRequest, starter : str , instance_id : str ):
755
751
client = df.DurableOrchestrationClient(starter)
756
752
753
+ # To suspend an orchestration
757
754
suspend_reason = " Need to pause workflow"
758
755
await client.suspend(instance_id, suspend_reason)
759
756
760
- # Wait for 30 seconds to ensure that the orchestrator state is updated to suspended.
761
- due_time = context.current_utc_datetime + timedelta(seconds = 30 )
762
- yield context.create_timer(due_time)
763
-
757
+ # To resume an orchestration
764
758
resume_reason = " Continue workflow"
765
759
await client.resume(instance_id, resume_reason)
766
760
```
@@ -770,20 +764,20 @@ async def main(req: func.HttpRequest, starter: str, instance_id: str):
770
764
``` powershell
771
765
param($Request, $TriggerMetadata)
772
766
773
- # Get instance id from body
774
767
$InstanceId = $Request.Body.InstanceId
775
- $SuspendReason = 'Need to pause workflow'
776
768
769
+ # To suspend an orchestration
770
+ $SuspendReason = 'Need to pause workflow'
777
771
Suspend-DurableOrchestration -InstanceId $InstanceId -Reason $SuspendReason
778
772
779
- # Wait for 30 seconds to ensure that the orchestrator state is updated to suspended.
780
- $duration = New-TimeSpan -Seconds 30
781
- Start-DurableTimer -Duration $duration
782
-
773
+ # To resume an orchestration
783
774
$ResumeReason = 'Continue workflow'
784
775
Resume-DurableOrchestration -InstanceId $InstanceId -Reason $ResumeReason
785
776
```
786
777
778
+ > [ !NOTE]
779
+ > This change applies only to the standalone [ Durable Functions PowerShell SDK] ( https://www.powershellgallery.com/packages/AzureFunctions.PowerShell.Durable.SDK ) , which is currently [ in preview] ( durable-functions-powershell-v2-sdk-migration-guide.md ) .
780
+
787
781
# [ Java] ( #tab/java )
788
782
789
783
``` java
@@ -793,14 +787,14 @@ public void suspendResumeInstance(
793
787
@DurableClientInput (name = " durableContext" ) DurableClientContext durableContext) {
794
788
String instanceID = req. getBody();
795
789
DurableTaskClient client = durableContext. getClient();
790
+
791
+ // To suspend an orchestration
796
792
String suspendReason = " Need to pause workflow" ;
797
793
client. suspendInstance(instanceID, suspendReason);
798
794
799
- // Wait for 30 seconds to ensure that the orchestrator state is updated to suspended.
800
- ctx. createTimer(Duration . ofSeconds(30 )). await();
801
-
795
+ // To resume an orchestration
802
796
String resumeReason = " Continue workflow" ;
803
- client. getClient() . resumeInstance(instanceID, resumeReason);
797
+ client. resumeInstance(instanceID, resumeReason);
804
798
}
805
799
```
806
800
0 commit comments