Skip to content

Commit a9833dd

Browse files
author
Jim Bennett
committed
Adding more documentation around the keys
1 parent e1e13c0 commit a9833dd

File tree

6 files changed

+72
-2
lines changed

6 files changed

+72
-2
lines changed

README.rst

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ To interact with Azure IoT Hub, you will need to create a hub, and a register a
8585

8686
- Open the `Azure Portal <https://aka.ms/AzurePortalHome>`_.
8787
- Follow the instructions in `Microsoft Docs <https://aka.ms/CreateIoTHub>`_ to create an Azure IoT Hub and register a device.
88-
- Copy the devices Primary Key, and add this to your ``secrets.py`` file.
88+
- Copy the devices Primary or secondary connection string, and add this to your ``secrets.py`` file.
89+
90+
You can find the device connection string by selecting the IoT Hub in the `Azure Portal <https://aka.ms/AzurePortalHome>`_, *selecting Explorer -> IoT devices*, then selecting your device.
91+
92+
:: images/iot-hub-device.png
93+
:alt: Locating the device in the IoT hub blade
94+
95+
Then copy either the primary or secondary connection string using the copy button next to the value.
96+
97+
:: images/iot-hub-device-keys.png
8998

9099
**Connect your device to Azure IoT Hub**
91100

@@ -162,7 +171,30 @@ To use Azure IoT Central, you will need to create an Azure IoT Central app, crea
162171
- Head to `Azure IoT Central <https://apps.azureiotcentral.com/?WT.mc_id=AdafruitCircuitPythonAzureIoT-github-jabenn>`__
163172
- Follow the instructions in the `Microsoft Docs <https://docs.microsoft.com/azure/iot-central/core/quick-deploy-iot-central?WT.mc_id=AdafruitCircuitPythonAzureIoT-github-jabenn>`__ to create an application. Every tier is free for up to 2 devices.
164173
- Follow the instructions in the `Microsoft Docs <https://docs.microsoft.com/azure/iot-central/core/quick-create-simulated-device?WT.mc_id=AdafruitCircuitPythonAzureIoT-github-jabenn>`__ to create a device template.
165-
- Create a device based off the template, and select **Connect** to get the device connection details. Store the ID Scope, Device ID and Primary Key in your ``secrets.py`` file.
174+
- Create a device based off the template, and select **Connect** to get the device connection details. Store the ID Scope, Device ID and either the Primary or secondary Key in your ``secrets.py`` file.
175+
176+
.. image:: images/iot-central-connect-button.png
177+
:alt: The IoT Central connect button
178+
179+
*The connect button*
180+
181+
.. image:: images/iot-central-connect-dialog.png
182+
:alt: The IoT Central connection details dialog
183+
184+
*The connection details dialog*
185+
186+
.. code-block:: python
187+
188+
secrets = {
189+
# WiFi settings
190+
"ssid": "",
191+
"password": "",
192+
193+
# Azure IoT Central settings
194+
"id_scope": "",
195+
"device_id": "",
196+
"key": ""
197+
}
166198
167199
**Connect your device to your Azure IoT Central app**
168200

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This file is where you keep secret settings, passwords, and tokens!
2+
# If you put them in the code you risk committing that info or sharing it
3+
# which would be not great. So, instead, keep it all in this one file and
4+
# keep it a secret.
5+
6+
# To find out how to hide any changes you make to this file from Git, check out
7+
# this blog post: https://www.jimbobbennett.io/hiding-api-keys-from-git/
8+
9+
"""
10+
Contains the secrets for your app including WiFi connection details.
11+
DO NOT CHECK THIS INTO SOURCE CODE CONTROL!!!!11!!!
12+
"""
13+
14+
secrets = {
15+
# WiFi settings
16+
"ssid": "",
17+
"password": "",
18+
19+
# Azure IoT Central settings - if you are connecting to Azure IoT Central, fill in these three values
20+
# To get these values, select your device in Azure IoT Central,
21+
# then select the Connect button
22+
# A dialog will appear with these three values
23+
# id_scope comes from the ID scope value
24+
# device_id comes from the Device ID value
25+
# key comes from either the Primary key or Secondary key
26+
"id_scope": "",
27+
"device_id": "",
28+
"key": "",
29+
30+
# Azure IoT Hub settings - if you are connecting to Azure IoT Hub, fill in this value
31+
# To get this value, from the Azure Portal (https://aka.ms/AzurePortalHome), select your IoT Hub,
32+
# then select Explorers -> IoT devices, select your device, then copy the entire primary or secondary
33+
# connection string using the copy button next to the value and set this here.
34+
# It will be in the format:
35+
# HostName=<your-hub>.azure-devices.net;DeviceId=<your device id>;SharedAccessKey=<key>
36+
# Note - you need the primary or secondary connection string, NOT the primary or secondary key
37+
"device_connection_string": "",
38+
}
18.7 KB
Loading
72.7 KB
Loading

images/iot-hub-device-keys.png

70.4 KB
Loading

images/iot-hub-device.png

69 KB
Loading

0 commit comments

Comments
 (0)