@@ -13,6 +13,8 @@ namespace Microsoft.DurableTask.Extensions.Azure;
1313/// </summary>
1414public class DurableTaskSchedulerOptions
1515{
16+ private readonly string defaultWorkerId ;
17+
1618 /// <summary>
1719 /// Initializes a new instance of the <see cref="DurableTaskSchedulerOptions"/> class.
1820 /// </summary>
@@ -28,6 +30,9 @@ internal DurableTaskSchedulerOptions(string endpointAddress, string taskHubName,
2830
2931 this . TaskHubName = taskHubName ;
3032 this . Credential = credential ;
33+
34+ // Generate the default worker ID once at construction time
35+ this . defaultWorkerId = $ "{ Environment . MachineName } ,{ Environment . ProcessId } ,{ Guid . NewGuid ( ) : N} ";
3136 }
3237
3338 /// <summary>
@@ -54,7 +59,7 @@ internal DurableTaskSchedulerOptions(string endpointAddress, string taskHubName,
5459
5560 /// <summary>
5661 /// Gets or sets the worker ID used to identify the worker instance.
57- /// The default value is a string containing the machine name and the process ID .
62+ /// The default value is a string containing the machine name, process ID, and a unique identifier .
5863 /// </summary>
5964 public string ? WorkerId { get ; set ; }
6065
@@ -78,8 +83,7 @@ internal GrpcChannel GetGrpcChannel()
7883 string endpoint = this . EndpointAddress ;
7984
8085 string resourceId = this . ResourceId ?? "https://durabletask.io" ;
81- int processId = Environment . ProcessId ;
82- string workerId = this . WorkerId ?? $ "{ Environment . MachineName } ,{ processId } ,{ Guid . NewGuid ( ) : N} ";
86+ string workerId = this . WorkerId ?? this . defaultWorkerId ;
8387
8488 AccessTokenCache ? cache =
8589 this . Credential is not null
0 commit comments