This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
495b950
commit 616cd7b
Showing
1 changed file
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
|
||
# Quickstart: Deploy your first IoT Edge module to a virtual Linux device | ||
|
||
Test out Azure IoT Edge in this quickstart by deploying containerized code to a virtual Linux IoT Edge device. IoT Edge allows you to remotely manage code on your devices so that you can send more of your workloads to the edge. For this quickstart, we recommend using an Azure virtual machine for your IoT Edge device, which allows you to quickly create a test machine with the IoT Edge service installed and then delete it when you're finished. | ||
|
||
In this quickstart you learn how to: | ||
|
||
* Create an IoT Hub. | ||
* Register an IoT Edge device to your IoT hub. | ||
* Install and start the IoT Edge runtime on your virtual device. | ||
|
||
|
||
![Diagram - Quickstart architecture for device and cloud](./media/quickstart-linux/install-edge-full.png) | ||
|
||
This quickstart walks you through creating a Linux virtual machine that's configured to be an IoT Edge device. Then, you deploy a module from the Azure portal to your device. The module used in this quickstart is a simulated sensor that generates temperature, humidity, and pressure data. The other Azure IoT Edge tutorials build upon the work you do here by deploying additional modules that analyze the simulated data for business insights. | ||
|
||
If you don't have an active Azure subscription, create a [free account](https://azure.microsoft.com/free) before you begin. | ||
|
||
[!INCLUDE [cloud-shell-try-it.md](../../includes/cloud-shell-try-it.md)] | ||
|
||
You use the Azure CLI to complete many of the steps in this quickstart, and Azure IoT has an extension to enable additional functionality. | ||
|
||
Add the Azure IoT extension to the Cloud Shell instance. | ||
|
||
```azurecli-interactive | ||
az extension add --name azure-iot | ||
``` | ||
|
||
[!INCLUDE [iot-hub-cli-version-info](../../includes/iot-hub-cli-version-info.md)] | ||
|
||
## Prerequisites | ||
|
||
Cloud resources: | ||
|
||
* A resource group to manage all the resources you use in this quickstart. We use the example resource group name **IoTEdgeResources** throughout this quickstart and the following tutorials. | ||
|
||
```azurecli-interactive | ||
az group create --name IoTEdgeResources --location westus2 | ||
``` | ||
|
||
## Create an IoT hub | ||
|
||
Start the quickstart by creating an IoT hub with Azure CLI. | ||
|
||
![Diagram - Create an IoT hub in the cloud](./media/quickstart-linux/create-iot-hub.png) | ||
|
||
The free level of IoT Hub works for this quickstart. If you've used IoT Hub in the past and already have a hub created, you can use that IoT hub. | ||
|
||
The following code creates a free **F1** hub in the resource group **IoTEdgeResources**. Replace `{hub_name}` with a unique name for your IoT hub. It might take a few minutes to create an IoT Hub. | ||
|
||
```azurecli-interactive | ||
az iot hub create --resource-group IoTEdgeResources --name {hub_name} --sku F1 --partition-count 2 | ||
``` | ||
|
||
If you get an error because there's already one free hub in your subscription, change the SKU to **S1**. Each subscription can only have one free IoT hub. If you get an error that the IoT Hub name isn't available, it means that someone else already has a hub with that name. Try a new name. | ||
|
||
## Register an IoT Edge device | ||
|
||
Register an IoT Edge device with your newly created IoT hub. | ||
|
||
![Diagram - Register a device with an IoT Hub identity](./media/quickstart-linux/register-device.png) | ||
|
||
Create a device identity for your IoT Edge device so that it can communicate with your IoT hub. The device identity lives in the cloud, and you use a unique device connection string to associate a physical device to a device identity. | ||
|
||
Since IoT Edge devices behave and can be managed differently than typical IoT devices, declare this identity to be for an IoT Edge device with the `--edge-enabled` flag. | ||
|
||
1. In the Azure Cloud Shell, enter the following command to create a device named **myEdgeDevice** in your hub. | ||
|
||
```azurecli-interactive | ||
az iot hub device-identity create --device-id myEdgeDevice --edge-enabled --hub-name {hub_name} | ||
``` | ||
|
||
If you get an error about iothubowner policy keys, make sure that your Cloud Shell is running the latest version of the azure-iot extension. | ||
|
||
2. View the connection string for your device, which links your physical device with its identity in IoT Hub. It contains the name of your IoT hub, the name of your device, and then a shared key that authenticates connections between the two. We'll refer to this connection string again in the next section when you set up your IoT Edge device. | ||
|
||
```azurecli-interactive | ||
az iot hub device-identity connection-string show --device-id myEdgeDevice --hub-name {hub_name} | ||
``` | ||
|
||
![View connection string from CLI output](./media/quickstart/retrieve-connection-string.png) | ||
|
||
## Configure your IoT Edge device | ||
|
||
Create a virtual machine with the Azure IoT Edge runtime on it. | ||
|
||
![Diagram - Start the runtime on device](./media/quickstart-linux/start-runtime.png) | ||
|
||
### Deploy the IoT Edge device | ||
|
||
This section uses an Azure Resource Manager template to create a new virtual machine and install the IoT Edge runtime on it. If you want to use your own Linux device instead, you can follow the installation steps in [Install the Azure IoT Edge runtime](how-to-install-iot-edge.md), then return to this quickstart. | ||
|
||
Use the following CLI command to create your IoT Edge device based on the prebuilt [iotedge-vm-deploy](https://github.com/Azure/iotedge-vm-deploy) template. | ||
|
||
The IoT Edge runtime is deployed on all IoT Edge devices. It has three components. The *IoT Edge security daemon* starts each time an IoT Edge device boots and bootstraps the device by starting the IoT Edge agent. The *IoT Edge agent* facilitates deployment and monitoring of modules on the IoT Edge device, including the IoT Edge hub. The *IoT Edge hub* manages communications between modules on the IoT Edge device, and between the device and IoT Hub. | ||
|
||
During the runtime configuration, you provide a device connection string. This is the string that you retrieved from the Azure CLI. This string associates your physical device with the IoT Edge device identity in Azure. |