Exercise - Deploy an IoT Edge device and manage it from IoT Central
Deploy the IoT Edge runtime to a Linux VM and manage your IoT Edge device from IoT Central.
In this unit, you'll deploy the IoT Edge runtime to a Linux Virtual Machine (VM) to test the behavior of your modules with your IoT Central application.
Configure and deploy the IoT Edge device
In the previous module, you learned that an IoT Edge device needs the connection information from the IoT Central application. Set the following environment variables in your Cloud Shell sandbox:
<AZURE_VM_USER_PASSWORD> with a strong password of your choice for your virtual machine:
<IOT_CENTRAL_APP_SCOPE_ID> with the scope ID you made a note of in the previous exercise:
<IOT_CENTRAL_DEVICE_KEY> with the device primary key you made a note of in the previous exercise:
The following command creates a Linux VM, installs the IoT Edge runtime, and edits the configuration file. By default, an IoT Edge installation connects directly to an IoT hub. The edits to the configuration file ensure that the IoT Edge device uses the Device Provisioning Service (DPS) to connect to your IoT Central application:
az deployment group create \ --name edgeModuleVM \ --resource-group <rgn>[sandbox resource group name]</rgn> \ --template-uri https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/edge-vm-deploy-1-4/edgeModuleVMDeploy.json \ --parameters dnsLabelPrefix="$APP_NAME" \ --parameters adminUsername="AzureUser" \ --parameters adminPassword="$VM_PASSWORD" \ --parameters scopeId="$SCOPE_ID" \ --parameters deviceId="store-001" \ --parameters deviceKey="$DEVICE_KEY"
Navigate to the Environmental Sensor Edge Device devices on the Devices page in your IoT Central application. If you've forgotten the URL, run the following command:
echo "You can now navigate to: https://$APP_NAME.azureiotcentral.com/devices"
The Device status changes from Registered to Provisioned when the IoT Edge device connects.
Expect to wait for several minutes for the status to change to Provisioned.
Wait until the Device status is Provisioned, then click on the device name store-001. You can see the available views for the device, including Modules. Select the Modules view. The status of the three modules changes to Running when the IoT Central application detects the modules are running. You may need to wait a couple of minutes for the status to update.
Monitor the telemetry
To view the telemetry coming from the IoT Edge device, select View IoT Edge device telemetry. This view is the one you created previously. After a few minutes, you'll see the telemetry on the line chart.
The IoT Edge module is sending some ambient temperature values less than 21°. In the next unit you'll learn how to filter these low values out at the edge.
You can also:
- View the raw data coming from the IoT Edge device on the Raw data page.
- Edit the cloud properties you defined on the Store information page.
- Edit the devices writable properties - Send Data and Send Interval - on the Manage page. IoT Central creates this page automatically for IoT Edge devices.
You now have an IoT Edge device running in an Azure VM, connected to your IoT Central application using DPS, and sending telemetry.