{"id":18149262,"url":"https://github.com/jongio/azure-iot-rest","last_synced_at":"2026-03-06T10:32:24.938Z","repository":{"id":69183452,"uuid":"109637260","full_name":"jongio/azure-iot-rest","owner":"jongio","description":null,"archived":false,"fork":false,"pushed_at":"2017-12-08T14:37:16.000Z","size":61,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T08:43:26.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jongio.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-06T02:21:04.000Z","updated_at":"2024-01-12T15:22:16.000Z","dependencies_parsed_at":"2023-05-01T16:02:32.996Z","dependency_job_id":null,"html_url":"https://github.com/jongio/azure-iot-rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jongio/azure-iot-rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Fazure-iot-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Fazure-iot-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Fazure-iot-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Fazure-iot-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongio","download_url":"https://codeload.github.com/jongio/azure-iot-rest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Fazure-iot-rest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30171869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-01T23:12:26.802Z","updated_at":"2026-03-06T10:32:24.917Z","avatar_url":"https://github.com/jongio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Azure IoT REST\n\nThis repo contains sample code that will help you use the Azure IoT REST APIs.\n\n## Prerequisites\n\n### Azure Requirements\n1. Azure IoT Hub\n1. Azure IoT Hub Device\n1. Azure Storage Account (to store the uploaded files, see [this blog post](http://blog.jongallant.com/2017/01/azure-iot-hub-file-upload-python/) for instructions on how to set this up)\n\n### Dev Machine Requirements\n1. Install [Python 2.7+](https://www.python.org/downloads/)\n1. Clone this repo `git clone https://github.com/jonbgallant/azure-iot-rest.git`\n1. Navigate to the root of this repo and run:\n    - Python 2: `pip install -r requirements.txt` \n    - Python 3: `pip3 install -r requirements.txt`\n1. Execute the scripts as indicated below.\n\n### Authentication\n\n#### Data Plane\nThe Azure IoT REST APIs hosted on azure-devices.net require a SAS Token Authorization header. You can find Python, Node and C# samples [here](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-security#security-tokens).\n\n#### Control Plane\nThe Azure REST APIs hosted on management.azure.com require a Bearer Token Authorization header. See [Azure REST APIs with Postman in 2 Minutes](http://blog.jongallant.com/azure-rest-apis-postman) for instructions on how to generate a Bearer Token.\n\n## APIs\n### Devices\n\n#### Modules\nEvery IoT Edge device has a list of modules associated.  You can use the `modules.py` script to retrieve them.\n\nTo get all modules:\n```\npython data-plane/device/modules/modules.py --name [iothubname] --key [iothubkey] --device-id [deviceid]\n```\n\nTo get a specific module:\n```\npython data-plane/device/modules/modules.py --name [iothubname] --key [iothubkey] --device-id [deviceid] --module-id [your module id]\n```\n\n#### Module Twin\n\nEvery IoT Edge device module has a corresponding cloud twin. You can use the `module-twin.py` script to retrieve that twin data.\n\n```\npython data-plane/device/modules/module-twin.py --name [iothubname] --key [iothubkey] --device-id [deviceid] --module-id [your module id]\n```\n\nTo get the $edgeHub module twin you would execute the following:  \n\n\u003e Make sure you single quote `$edgeHub`\n\n```\npython data-plane/device/modules/module-twin.py --name [iothubname] --key [iothubkey] --device-id [deviceid] --module-id '$edgeHub'\n```\n\nThat will output a json object that you can inspect.\n\nThe URI path is:\n```\nhttps://[iotname].azure-devices.net/twins/[deviceId]/modules/[moduleId]?api-version=[api-version]\n```\n\n#### Configuration\n\nIoT Edge devices are configured with metadata such as module paths and route settings.  That configuration is applied via the `applyConfigurationContent` API.  You can read more about Edge configuration [here](https://github.com/jonbgallant/azure-iot-edge-config).\n\nHere's how to apply a configuration update:\n\n##### Script\n\n```\npython data-plane/devices/device-conf.py --name [iothubname] --key [iothubkey] --device-id [deviceid] --config-file [path to module config]\n```\n\n##### REST API\n\n```\nPOST /devices/{{deviceId}}/applyConfigurationContent?api-version=2017-11-08-preview HTTP/1.1\nHost: {{iot-hub-name}}.azure-devices.net\nAuthorization: {{sas-token}}\nContent-Type: application/json\n```\n\nThe POST payload needs to be the modified version of the moduleconfig.json file found [here](https://github.com/jonbgallant/azure-iot-edge-config/blob/master/config/moduleconfig.json).\n\n#### File Upload\n\nThe Azure IoT File Upload process is as follows:\n\n1. Make a request to get the blob storage URI that includes the SAS Token\n2. Put the file at the blob storage URI you received in the previous step\n3. Call the notification URI to check the status of the upload\n\nHere's how to upload a file:\n\n##### Script\n\n\u003e Make sure you have the storage account setup as indicated above in the [prerequisites](#prerequisites).\n\n```\npython data-plane/devices/files/file-upload.py --name [iothubname] --key [iothubkey] --device-id [deviceid]\n```\n\nThis script will upload a couple of sample files to prove it works.  Feel free to customize the script to suit your needs.\n\n#### File Upload Notifications\n\nPlease reference the following article to learn how to handle the File Upload Notification event on the server-side.  This is helpful when you want to kick-off a backend process when a file has been uploaded.\n\nhttps://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-java-java-file-upload#receive-a-file-upload-notification","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongio%2Fazure-iot-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongio%2Fazure-iot-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongio%2Fazure-iot-rest/lists"}