Note the ssh command from the value key in previous command's output and use it to login to the VM. For example ssh -i ~/.ssh/id_lab azureuser@iotedge-vm-xyz.westus2.cloudapp.azure.com.
It can take about 2 minutes for the VM to complete provisioning, enter watch sudo iotedge list in the VM's bash shell and wait for the edgeAgent module to be reported as running. It is expected to see "command not found" initially. Ctrl+c returns you to the VM's shell.
Type exit in the VM's SSH shell to return the cloud shell environment
Go to the portal page for IoT Hub created in the prior step. If you are having trouble finding it, enter the unique string you chose in the search bar after ensuring the subscription you are using is selected.
Select the IoT Edge ToC item and click on the device you created earlier.
On the device details page, click the Set modules button on the top left
Click on + Add and select + IoT Edge Module
In the Add IoT Edge Module screen, enter tempSensor for Module name and mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0.10 for Image URI. Then click the Add button at the bottom.
Back on the Set Modules screen, click Review + create followed by Create to set the workload.
In a few seconds, you should see the tempSensor module listed in output of sudo iotedge list on the VM created in the previous step.
Now, to monitor the edge device we'll add the Azure Monitor IoT Edge module.
Note the Resource ID of the IoT Hub from the Properties ToC item:
Select the IoT Edge ToC item and click on the device you created earlier.
On the device details page, click the Set modules button on the top left
Click on + Add and select + IoT Edge Module
In the Add IoT Edge Module pane, enter azmonitor for Module name and mcr.microsoft.com/azuremonitor/containerinsights/ciprod:iot-0.1.3.2-amd64 for Image URI.
On the same pane, click on the Environment Variables tab and add two variables with names and values noted below:
(The last two characters of the shared key are ==)
Click the Add button at the bottom to confirm module settings, followed by Review + create and Create on the Set Modules screen.
In a few seconds, you should see the azmonitor module listed in output of sudo iotedge list on the VM created earlier.
In a few minutes, you can visualize detailed metrics from the device right in the IoT Hub portal page with Azure Monitor Workbooks!
Check out this 5-min video demo that explores the visualizations enabled using Azure Monitor Workbooks.
Congratulations on completing the lab! If you are interested in exploring more about this feature including how to monitor metrics from your custom module using this solution and at-scale alerting, please sign up for the preview at https://aka.ms/edgemon-intake