Share via


DigitalTwinsClient Constructors

Definition

Overloads

DigitalTwinsClient()

Creates a new instance of the DigitalTwinsClient class, provided for unit testing purposes only.

DigitalTwinsClient(Uri, TokenCredential)

Creates a new instance of the DigitalTwinsClient class.

DigitalTwinsClient(Uri, TokenCredential, DigitalTwinsClientOptions)

Creates a new instance of the DigitalTwinsClient class, with options.

DigitalTwinsClient()

Source:
DigitalTwinsClient.cs

Creates a new instance of the DigitalTwinsClient class, provided for unit testing purposes only.

protected DigitalTwinsClient ();
Protected Sub New ()

Applies to

DigitalTwinsClient(Uri, TokenCredential)

Source:
DigitalTwinsClient.cs

Creates a new instance of the DigitalTwinsClient class.

public DigitalTwinsClient (Uri endpoint, Azure.Core.TokenCredential credential);
new Azure.DigitalTwins.Core.DigitalTwinsClient : Uri * Azure.Core.TokenCredential -> Azure.DigitalTwins.Core.DigitalTwinsClient
Public Sub New (endpoint As Uri, credential As TokenCredential)

Parameters

endpoint
Uri

The Azure digital twins service instance URI to connect to.

credential
TokenCredential

The TokenCredential implementation which will be used to request for the authentication token.

Examples

// DefaultAzureCredential supports different authentication mechanisms and determines the appropriate credential type based of the environment it is executing in.
// It attempts to use multiple credential types in an order until it finds a working credential.
TokenCredential tokenCredential = new DefaultAzureCredential();

var client = new DigitalTwinsClient(
    new Uri(adtEndpoint),
    tokenCredential);

Remarks

For more samples, see our repo samples.

See also

Applies to

DigitalTwinsClient(Uri, TokenCredential, DigitalTwinsClientOptions)

Source:
DigitalTwinsClient.cs

Creates a new instance of the DigitalTwinsClient class, with options.

public DigitalTwinsClient (Uri endpoint, Azure.Core.TokenCredential credential, Azure.DigitalTwins.Core.DigitalTwinsClientOptions options);
new Azure.DigitalTwins.Core.DigitalTwinsClient : Uri * Azure.Core.TokenCredential * Azure.DigitalTwins.Core.DigitalTwinsClientOptions -> Azure.DigitalTwins.Core.DigitalTwinsClient
Public Sub New (endpoint As Uri, credential As TokenCredential, options As DigitalTwinsClientOptions)

Parameters

endpoint
Uri

The Azure digital twins service instance URI to connect to.

credential
TokenCredential

The TokenCredential implementation which will be used to request for the authentication token.

options
DigitalTwinsClientOptions

Options that allow configuration of requests sent to the digital twins service.

Examples

// This illustrates how to specify client options, in this case, by providing an
// instance of HttpClient for the digital twins client to use.
var clientOptions = new DigitalTwinsClientOptions
{
    Transport = new HttpClientTransport(httpClient),
};

// By using the InteractiveBrowserCredential, the current user can login using a web browser
// interactively with the AAD
var tokenCredential = new InteractiveBrowserCredential(
    tenantId,
    clientId,
    new TokenCredentialOptions { AuthorityHost = KnownAuthorityHosts.AzureCloud });

var client = new DigitalTwinsClient(
    new Uri(adtEndpoint),
    tokenCredential,
    clientOptions);

Remarks

The options parameter provides an opportunity to override default behavior, including specifying API version, overriding transport, enabling diagnostics, and controlling retry strategy.

For more samples, see our repo samples.

Applies to