ServiceClient.Create Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Create(String, AzureSasCredential, TransportType, ServiceClientTransportSettings, ServiceClientOptions) |
Creates ServiceClient using a shared access signature provided and refreshed as necessary by the caller. |
Create(String, TokenCredential, TransportType, ServiceClientTransportSettings, ServiceClientOptions) |
Creates ServiceClient, authenticating using an identity in Azure Active Directory (AAD). |
Create(String, AzureSasCredential, TransportType, ServiceClientTransportSettings, ServiceClientOptions)
Creates ServiceClient using a shared access signature provided and refreshed as necessary by the caller.
public static Microsoft.Azure.Devices.ServiceClient Create (string hostName, Azure.AzureSasCredential credential, Microsoft.Azure.Devices.TransportType transportType = Microsoft.Azure.Devices.TransportType.Amqp, Microsoft.Azure.Devices.ServiceClientTransportSettings transportSettings = default, Microsoft.Azure.Devices.ServiceClientOptions options = default);
static member Create : string * Azure.AzureSasCredential * Microsoft.Azure.Devices.TransportType * Microsoft.Azure.Devices.ServiceClientTransportSettings * Microsoft.Azure.Devices.ServiceClientOptions -> Microsoft.Azure.Devices.ServiceClient
Public Shared Function Create (hostName As String, credential As AzureSasCredential, Optional transportType As TransportType = Microsoft.Azure.Devices.TransportType.Amqp, Optional transportSettings As ServiceClientTransportSettings = Nothing, Optional options As ServiceClientOptions = Nothing) As ServiceClient
Parameters
- hostName
- String
IoT hub host name.
- credential
- AzureSasCredential
Credential that generates a SAS token to authenticate with IoT hub. See AzureSasCredential.
- transportType
- TransportType
Specifies whether Amqp or Amqp_WebSocket_Only transport is used.
- transportSettings
- ServiceClientTransportSettings
Specifies the AMQP_WS and HTTP proxy settings for service client.
- options
- ServiceClientOptions
The options that allow configuration of the service client instance during initialization.
Returns
A ServiceClient instance.
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
Create(String, TokenCredential, TransportType, ServiceClientTransportSettings, ServiceClientOptions)
Creates ServiceClient, authenticating using an identity in Azure Active Directory (AAD).
public static Microsoft.Azure.Devices.ServiceClient Create (string hostName, Azure.Core.TokenCredential credential, Microsoft.Azure.Devices.TransportType transportType = Microsoft.Azure.Devices.TransportType.Amqp, Microsoft.Azure.Devices.ServiceClientTransportSettings transportSettings = default, Microsoft.Azure.Devices.ServiceClientOptions options = default);
static member Create : string * Azure.Core.TokenCredential * Microsoft.Azure.Devices.TransportType * Microsoft.Azure.Devices.ServiceClientTransportSettings * Microsoft.Azure.Devices.ServiceClientOptions -> Microsoft.Azure.Devices.ServiceClient
Public Shared Function Create (hostName As String, credential As TokenCredential, Optional transportType As TransportType = Microsoft.Azure.Devices.TransportType.Amqp, Optional transportSettings As ServiceClientTransportSettings = Nothing, Optional options As ServiceClientOptions = Nothing) As ServiceClient
Parameters
- hostName
- String
IoT hub host name.
- credential
- TokenCredential
Azure Active Directory credentials to authenticate with IoT hub. See TokenCredential
- transportType
- TransportType
Specifies whether Amqp or Amqp_WebSocket_Only transport is used.
- transportSettings
- ServiceClientTransportSettings
Specifies the AMQP_WS and HTTP proxy settings for service client.
- options
- ServiceClientOptions
The options that allow configuration of the service client instance during initialization.
Returns
A ServiceClient instance.
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