title | description | author | manager | ms.author | ms.date | ms.topic | ms.reviewer | ms.service | services |
---|---|---|---|---|---|---|---|---|---|
Deploy modules from Visual Studio Code - Azure IoT Edge |
Use Visual Studio Code with the Azure IoT Tools to push an IoT Edge module from your IoT Hub to your IoT Edge device, as configured by a deployment manifest. |
kgremban |
philmea |
kgremban |
01/8/2019 |
conceptual |
iot-edge |
iot-edge |
Once you create IoT Edge modules with your business logic, you want to deploy them to your devices to operate at the edge. If you have multiple modules that work together to collect and process data, you can deploy them all at once and declare the routing rules that connect them.
This article shows how to create a JSON deployment manifest, then use that file to push the deployment to an IoT Edge device. For information about creating a deployment that targets multiple devices based on their shared tags, see Deploy IoT Edge modules at scale using Visual Studio Code.
- An IoT hub in your Azure subscription.
- An IoT Edge device with the IoT Edge runtime installed.
- Visual Studio Code.
- Azure IoT Tools for Visual Studio Code.
A deployment manifest is a JSON document that describes which modules to deploy, how data flows between the modules, and desired properties of the module twins. For more information about how deployment manifests work and how to create them, see Understand how IoT Edge modules can be used, configured, and reused.
To deploy modules using Visual Studio Code, save the deployment manifest locally as a .JSON file. You will use the file path in the next section when you run the command to apply the configuration to your device.
Here's a basic deployment manifest with one module as an example:
{
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.0",
"runtime": {
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": "",
"registryCredentials": {}
}
},
"systemModules": {
"edgeAgent": {
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.0",
"createOptions": "{}"
}
},
"edgeHub": {
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"443/tcp\":[{\"HostPort\":\"443\"}],\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}]}}}"
}
}
},
"modules": {
"SimulatedTemperatureSensor": {
"version": "1.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0",
"createOptions": "{}"
}
}
}
}
},
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.0",
"routes": {
"route": "FROM /messages/* INTO $upstream"
},
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
}
}
},
"SimulatedTemperatureSensor": {
"properties.desired": {}
}
}
}
You can use the Azure IoT extensions for Visual Studio Code to perform operations with your IoT hub. For these operations to work, you need to sign in to your Azure account and select the IoT hub that you are working on.
-
In Visual Studio Code, open the Explorer view.
-
At the bottom of the Explorer, expand the Azure IoT Hub section.
-
Click on the ... in the Azure IoT Hub section header. If you don't see the ellipsis, hover over the header.
-
Choose Select IoT Hub.
-
If you are not signed in to your Azure account, follow the prompts to do so.
-
Select your Azure subscription.
-
Select your IoT hub.
You deploy modules to your device by applying the deployment manifest that you configured with the module information.
-
In the Visual Studio Code explorer view, expand the Azure IoT Hub section, and then expand the Devices node.
-
Right-click on the IoT Edge device that you want to configure with the deployment manifest.
[!TIP] To confirm that the device you've chosen is an IoT Edge device, select it to expand the list of modules and verify the presence of $edgeHub and $edgeAgent. Every IoT Edge device includes these two modules.
-
Select Create Deployment for Single Device.
-
Navigate to the deployment manifest JSON file that you want to use, and click Select Edge Deployment Manifest.
The results of your deployment are printed in the VS Code output. Successful deployments are applied within a few minutes if the target device is running and connected to the internet.
Once you've deployed modules to your device, you can view all of them in the Azure IoT Hub section. Select the arrow next to your IoT Edge device to expand it. All the currently running modules are displayed.
If you recently deployed new modules to a device, hover over the Azure IoT Hub Devices section header and select the refresh icon to update the view.
Right-click the name of a module to view and edit the module twin.
Learn how to Deploy and monitor IoT Edge modules at scale using Visual Studio Code