Udostępnij za pośrednictwem


IotHubServiceClient Constructors

Definition

Overloads

IotHubServiceClient()

Creates an instance of this class. Provided for unit testing purposes only.

IotHubServiceClient(String, IotHubServiceClientOptions)

Create an instance of this class that authenticates service requests using an IoT hub connection string.

IotHubServiceClient(String, AzureSasCredential, IotHubServiceClientOptions)

Create an instance of this class that authenticates service requests with a shared access signature provided and refreshed as necessary by the caller.

IotHubServiceClient(String, TokenCredential, IotHubServiceClientOptions)

Create an instance of this class that authenticates service requests using an identity in Azure Active Directory (AAD).

IotHubServiceClient()

Creates an instance of this class. Provided for unit testing purposes only.

protected IotHubServiceClient ();
Protected Sub New ()

Applies to

IotHubServiceClient(String, IotHubServiceClientOptions)

Create an instance of this class that authenticates service requests using an IoT hub connection string.

public IotHubServiceClient (string connectionString, Microsoft.Azure.Devices.IotHubServiceClientOptions options = default);
new Microsoft.Azure.Devices.IotHubServiceClient : string * Microsoft.Azure.Devices.IotHubServiceClientOptions -> Microsoft.Azure.Devices.IotHubServiceClient
Public Sub New (connectionString As String, Optional options As IotHubServiceClientOptions = Nothing)

Parameters

connectionString
String

The IoT hub connection string.

options
IotHubServiceClientOptions

The optional client settings.

Exceptions

Thrown when the provided connection string is null.

Thrown when the provided connection string is empty or whitespace.

Applies to

IotHubServiceClient(String, AzureSasCredential, IotHubServiceClientOptions)

Create an instance of this class that authenticates service requests with a shared access signature provided and refreshed as necessary by the caller.

public IotHubServiceClient (string hostName, Azure.AzureSasCredential credential, Microsoft.Azure.Devices.IotHubServiceClientOptions options = default);
new Microsoft.Azure.Devices.IotHubServiceClient : string * Azure.AzureSasCredential * Microsoft.Azure.Devices.IotHubServiceClientOptions -> Microsoft.Azure.Devices.IotHubServiceClient
Public Sub New (hostName As String, credential As AzureSasCredential, Optional options As IotHubServiceClientOptions = Nothing)

Parameters

hostName
String

IoT hub host name. For instance: "my-iot-hub.azure-devices.net".

credential
AzureSasCredential

Credential that generates a SAS token to authenticate with IoT hub. See AzureSasCredential.

options
IotHubServiceClientOptions

The optional client settings.

Exceptions

Thrown when the provided hostName or credential is null.

Thrown when the provided hostName is empty or whitespace.

Remarks

Users may wish to build their own shared access signature (SAS) tokens rather than give the shared key to the SDK and let it manage signing and renewal. The AzureSasCredential object gives the SDK access to the SAS token, while the caller can update it as necessary using the Update(String) method.

Applies to

IotHubServiceClient(String, TokenCredential, IotHubServiceClientOptions)

Create an instance of this class that authenticates service requests using an identity in Azure Active Directory (AAD).

public IotHubServiceClient (string hostName, Azure.Core.TokenCredential credential, Microsoft.Azure.Devices.IotHubServiceClientOptions options = default);
new Microsoft.Azure.Devices.IotHubServiceClient : string * Azure.Core.TokenCredential * Microsoft.Azure.Devices.IotHubServiceClientOptions -> Microsoft.Azure.Devices.IotHubServiceClient
Public Sub New (hostName As String, credential As TokenCredential, Optional options As IotHubServiceClientOptions = Nothing)

Parameters

hostName
String

IoT hub host name. For instance: "my-iot-hub.azure-devices.net".

credential
TokenCredential

Azure Active Directory (AAD) credentials to authenticate with IoT hub.

options
IotHubServiceClientOptions

The optional client settings.

Exceptions

Thrown when the provided hostName or credential is null.

Thrown when the provided hostName is empty or whitespace.

Remarks

For more about information on the options of authenticating using a derived instance of TokenCredential, see https://docs.microsoft.com/dotnet/api/overview/azure/identity-readme. For more information on configuring IoT hub with Azure Active Directory, see https://docs.microsoft.com/azure/iot-hub/iot-hub-dev-guide-azure-ad-rbac

Applies to