/// <summary> /// Creates an instance of <see cref="JobClient"/>. /// </summary> /// <param name="hostName">IoT hub host name.</param> /// <param name="credential">Azure Active Directory credentials to authenticate with IoT hub. See <see cref="TokenCredential"/></param> /// <param name="transportSettings">The HTTP transport settings.</param> /// <param name="options">Options that allow configuration of the JobClient instance during initialization.</param> /// <returns>An instance of <see cref="JobClient"/>.</returns> /// <remarks> /// For more information on configuring IoT hub with Azure Active Directory, see <see href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-dev-guide-azure-ad-rbac"/> /// This constructor sets the default for <see cref="JobClientOptions.TokenCredentialAuthenticationScopes"/> to /// <see cref="IotHubAuthenticationScopes.DefaultAuthenticationScopes"/>, which is used for any public or private cloud other than Azure US Government cloud. /// For Azure US Government cloud users, set the <see cref="JobClientOptions.TokenCredentialAuthenticationScopes"/> /// to <see cref="IotHubAuthenticationScopes.AzureGovernmentAuthenticationScopes"/>. /// </remarks> public static JobClient Create( string hostName, TokenCredential credential, HttpTransportSettings transportSettings = default, JobClientOptions options = default) { if (string.IsNullOrEmpty(hostName)) { throw new ArgumentNullException(nameof(hostName), "Parameter cannot be null or empty."); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } if (options == null) { options = new JobClientOptions(); } var tokenCredentialProperties = new IotHubTokenCrendentialProperties( hostName, credential, options.TokenCredentialAuthenticationScopes); return(new HttpJobClient(tokenCredentialProperties, transportSettings ?? new HttpTransportSettings())); }
internal HttpJobClient(IotHubConnectionString connectionString, HttpTransportSettings transportSettings) { _httpClientHelper = new HttpClientHelper( connectionString.HttpsEndpoint, connectionString, ExceptionHandlingHelper.GetDefaultErrorMapping(), s_defaultOperationTimeout, transportSettings.Proxy); }
/// <summary> /// Creates a JobClient from the Iot Hub connection string and HTTP transport settings /// </summary> /// <param name="connectionString"> The Iot Hub connection string.</param> /// <param name="transportSettings"> The HTTP transport settings.</param> /// <returns> A JobClient instance. </returns> public static JobClient CreateFromConnectionString(string connectionString, HttpTransportSettings transportSettings) { #if NET451 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; #endif var iotHubConnectionString = IotHubConnectionString.Parse(connectionString); return new HttpJobClient(iotHubConnectionString, transportSettings); }
internal HttpJobClient(IotHubConnectionProperties connectionProperties, HttpTransportSettings transportSettings) { _httpClientHelper = new HttpClientHelper( connectionProperties.HttpsEndpoint, connectionProperties, ExceptionHandlingHelper.GetDefaultErrorMapping(), s_defaultOperationTimeout, transportSettings.Proxy, transportSettings.ConnectionLeaseTimeoutMilliseconds); }
/// <summary> /// Creates a JobClient from the Iot Hub connection string and HTTP transport settings /// </summary> /// <param name="connectionString"> The Iot Hub connection string.</param> /// <param name="transportSettings"> The HTTP transport settings.</param> /// <returns> A JobClient instance. </returns> public static JobClient CreateFromConnectionString(string connectionString, HttpTransportSettings transportSettings) { if (transportSettings == null) { throw new ArgumentNullException(nameof(transportSettings), "HTTP Transport settings cannot be null."); } TlsVersions.Instance.SetLegacyAcceptableVersions(); var iotHubConnectionString = IotHubConnectionString.Parse(connectionString); return(new HttpJobClient(iotHubConnectionString, transportSettings)); }
/// <summary> /// Creates an instance of <see cref="JobClient"/>. /// </summary> /// <param name="hostName">IoT hub host name.</param> /// <param name="credential">Credential that generates a SAS token to authenticate with IoT hub. See <see cref="AzureSasCredential"/>.</param> /// <param name="transportSettings">The HTTP transport settings.</param> /// <returns>An instance of <see cref="JobClient"/>.</returns> public static JobClient Create( string hostName, AzureSasCredential credential, HttpTransportSettings transportSettings = default) { if (string.IsNullOrEmpty(hostName)) { throw new ArgumentNullException(nameof(hostName), "Parameter cannot be null or empty."); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } var sasCredentialProperties = new IotHubSasCredentialProperties(hostName, credential); return(new HttpJobClient(sasCredentialProperties, transportSettings ?? new HttpTransportSettings())); }
/// <summary> /// Creates JobClient, authenticating using an identity in Azure Active Directory (AAD). /// </summary> /// <remarks> /// For more about information on the options of authenticating using a derived instance of <see cref="TokenCredential"/>, see /// <see href="https://docs.microsoft.com/dotnet/api/overview/azure/identity-readme"/>. /// For more information on configuring IoT hub with Azure Active Directory, see /// <see href="https://docs.microsoft.com/azure/iot-hub/iot-hub-dev-guide-azure-ad-rbac"/> /// </remarks> /// <param name="hostName">IoT hub host name.</param> /// <param name="credential">Azure Active Directory (AAD) credentials to authenticate with IoT hub. See <see cref="TokenCredential"/></param> /// <param name="transportSettings">The HTTP transport settings.</param> /// <returns>A JobClient instance.</returns> public static JobClient Create( string hostName, TokenCredential credential, HttpTransportSettings transportSettings = default) { if (string.IsNullOrEmpty(hostName)) { throw new ArgumentNullException(nameof(hostName)); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential); return(new JobClient(tokenCredentialProperties, transportSettings ?? new HttpTransportSettings())); }
/// <summary> /// Creates a JobClient from the Iot Hub connection string and HTTP transport settings /// </summary> /// <param name="connectionString"> The Iot Hub connection string.</param> /// <param name="transportSettings"> The HTTP transport settings.</param> /// <returns> A JobClient instance. </returns> public static JobClient CreateFromConnectionString(string connectionString, HttpTransportSettings transportSettings) { var iotHubConnectionString = IotHubConnectionString.Parse(connectionString); return(new HttpJobClient(iotHubConnectionString, transportSettings)); }