Skip to content

erandermsft/iothubmqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

iothubmqtt

Shows two ways of connecting to IOT Hub directly over MQTT.
A practical adaptation of the guidelines here: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support

Pre-requisites:

  1. Install Azure CLI https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
  2. Install IOT Extensions for Azure CLI
    az extension add --name azure-cli-iot-ext

X509 Cert

  1. Create a device identity with a self-signed cert that is valid for 10 days using
    az iot hub device-identity create -n <hubname> -d <deviceid> --am x509_thumbprint --valid-days 10 --od .
    This will generate two files <deviceid>-cert.pem and <deviceid>-key.pem in the current folder
  2. Modify iothubcert.py by setting:
    device_id=<deviceid>
    iot_hub_name=<hubname>
  3. Run iothubcert.py. It should connect and send one message to IOT Hub over MQTT.

SAS

  1. Create a device identity with a SAS Token:
    az iot hub generate-sas-token -d <deviceid> -n <hubname>
    The token is the entire returned value, i.e.
    SharedAccessSignature sig={signature-string}&se={expiry}&sr={URL-encoded-resourceURI}
  2. Modify iothubsas.py by setting:
    device_id=<deviceid>
    iot_hub_name=<hubname>
    sas_token=<value of sas token generated in step 1>
  3. Run iothubsas.py. It should connect and send one message to IOT Hub over MQTT.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages