Skip to content

key word arguments during client creations

olivakar edited this page Jul 30, 2020 · 1 revision

Our azure-iot-device package offers various key-word arguments aka kwargs to enable the user pass in options during creations of clients.

defined kwargs

kwarg type meaning default values
product_info string arbitary information about the product that will be
appended to the user agent used for tracking purposes
empty ("")
websockets boolean indicator which shows usage of protocol over websockets, relevant
if a firewall blocks port 8883 for MQTT from use.
False
cipher string or list of strings set of algorithms, more specifically a set of steps
for performing any cryptographic function
empty ("")
server_verification_cert string (content of pem or der files) the trusted certificate chain, necessary when connecting to an endpoint
which has a non-standard root of trust, such as a protocol gateway.
None
proxy_options class azure.iot.device.ProxyOptions options for sending traffic through proxy servers None
sastoken_ttl int (in seconds) the time to live for the created SasToken used for authentication 3600
keep_alive int (in seconds) Maximum period in seconds between communications with the broker.
If no other messages are being exchanged, this controls the
rate at which the client will send ping messages to the broker
60

kwargs usage for Device/Module client creation APIs

kwarg create_from_connection_string create_from_x509_certificate create_from_symmetric_key create_from_edge_environment
product_info ✔️ ✔️ ✔️ ✔️
websockets ✔️ ✔️ ✔️ ✔️
cipher ✔️ ✔️ ✔️ ✔️
server_verification_cert ✔️ ✔️ ✔️
proxy_options ✔️ ✔️ ✔️ ✔️
sastoken_ttl ✔️ ✔️ ✔️
keep_alive ✔️ ✔️ ✔️ ✔️

example

device_client = IoTHubDeviceClient.create_from_connection_string(conn_str, websockets=True)

kwargs usage for provisioning client creation APIs

kwarg create_from_x509_certificate create_from_symmetric_key
product_info ✔️ ✔️
websockets ✔️ ✔️
cipher ✔️ ✔️
server_verification_cert ✔️ ✔️
proxy_options ✔️ ✔️
sastoken_ttl ✔️
keep_alive ✔️ ✔️

example

provisioning_device_client = ProvisioningDeviceClient.create_from_symmetric_key(
        provisioning_host=provisioning_host,
        registration_id=registration_id,
        id_scope=id_scope,
        symmetric_key=symmetric_key,
        keep_alive=65
)