2525
2626# Client class used for Durable Task Scheduler (DTS)
2727class DurableTaskSchedulerClient (TaskHubGrpcClient ):
28+ """A client for Azure Durable Task Scheduler.
29+
30+ ``resource_id`` optionally overrides the token audience. If None or empty,
31+ it defaults to ``https://durabletask.azure.us`` when ``REGION_NAME`` starts
32+ with ``usgov`` or ``usdod`` (case-insensitive), or ``https://durabletask.io``
33+ otherwise. Surrounding whitespace, trailing slashes, and an existing
34+ ``/.default`` suffix are removed before requesting the ``/.default`` scope.
35+ Values that become empty raise ``ValueError``. This does not configure the
36+ service endpoint or the credential's authority.
37+ """
38+
2839 def __init__ (self , * ,
2940 host_address : str ,
3041 taskhub : str ,
3142 token_credential : TokenCredential | None ,
43+ resource_id : str | None = None ,
3244 channel : grpc .Channel | None = None ,
3345 secure_channel : bool = True ,
3446 interceptors : Sequence [shared .ClientInterceptor ] | None = None ,
@@ -47,7 +59,8 @@ def __init__(self, *,
4759 resolved_interceptors : list [shared .ClientInterceptor ] = (
4860 list (interceptors ) if interceptors is not None else []
4961 )
50- resolved_interceptors .append (DTSDefaultClientInterceptorImpl (token_credential , taskhub ))
62+ resolved_interceptors .append (DTSDefaultClientInterceptorImpl (
63+ token_credential , taskhub , resource_id = resource_id ))
5164
5265 # We pass in None for the metadata so we don't construct an additional interceptor in the parent class
5366 # Since the parent class doesn't use anything metadata for anything else, we can set it as None
@@ -81,6 +94,12 @@ class AsyncDurableTaskSchedulerClient(AsyncTaskHubGrpcClient):
8194 taskhub (str): The name of the task hub. Cannot be empty.
8295 token_credential (TokenCredential | None): Azure credential for authentication.
8396 If None, anonymous authentication will be used.
97+ resource_id (str | None, optional): Token audience override. If None or empty,
98+ defaults to ``https://durabletask.azure.us`` when ``REGION_NAME`` starts
99+ with ``usgov`` or ``usdod`` (case-insensitive), or ``https://durabletask.io``
100+ otherwise. Surrounding whitespace, trailing slashes, and an existing
101+ ``/.default`` suffix are removed before requesting the ``/.default`` scope.
102+ Does not configure the service endpoint or the credential's authority.
84103 secure_channel (bool, optional): Whether to use a secure gRPC channel (TLS).
85104 Defaults to True.
86105 resiliency_options (GrpcClientResiliencyOptions | None, optional): Client-side
@@ -98,6 +117,7 @@ class AsyncDurableTaskSchedulerClient(AsyncTaskHubGrpcClient):
98117
99118 Raises:
100119 ValueError: If taskhub is empty or None.
120+ ValueError: If resource_id becomes empty after normalization.
101121
102122 Example:
103123 >>> from azure.identity.aio import DefaultAzureCredential
@@ -116,6 +136,7 @@ def __init__(self, *,
116136 host_address : str ,
117137 taskhub : str ,
118138 token_credential : AsyncTokenCredential | None ,
139+ resource_id : str | None = None ,
119140 channel : grpc .aio .Channel | None = None ,
120141 secure_channel : bool = True ,
121142 interceptors : Sequence [shared .AsyncClientInterceptor ] | None = None ,
@@ -134,7 +155,8 @@ def __init__(self, *,
134155 resolved_interceptors : list [shared .AsyncClientInterceptor ] = (
135156 list (interceptors ) if interceptors is not None else []
136157 )
137- resolved_interceptors .append (DTSAsyncDefaultClientInterceptorImpl (token_credential , taskhub ))
158+ resolved_interceptors .append (DTSAsyncDefaultClientInterceptorImpl (
159+ token_credential , taskhub , resource_id = resource_id ))
138160
139161 # We pass in None for the metadata so we don't construct an additional interceptor in the parent class
140162 # Since the parent class doesn't use anything metadata for anything else, we can set it as None
0 commit comments