Develop and debug ARM64 IoT Edge modules in Visual Studio Code
With the release of IoT Edge 1.0.8, developers can preview the IoT Edge support on ARM64 IoT Edge devices. In the meanwhile, I’m glad to share the steps of developing and debugging ARM64 IoT Edge custom modules in VS Code.
Prerequisites
This post assumes that you use a computer or virtual machine running Windows, Linux or macOS as your development machine, follow the instructions to set up your develop machine with VS Code. Your IoT Edge device can be another physical device. Typically the device can be an Raspberry Pi 3 or 4 (Follow the instructions on ubuntu.com to get ARM64 Ubuntu OS image for your Pi and install or update IoT Edge 1.0.8 on it).
If you are developing C# ARM64 custom module for IoT Edge, please download and install .NET Core 3.0 on your development machine.
Develop and deploy custom module project for ARM64
In this section, I will use C# custom module as an example. You add a new os/arch option for your IoT Edge tools in VS Code and use preview template for your C# custom module. For the rest of languages, you can see the specific steps in the last section of this blog post.
- In VS Code Command Palette (Ctrl + Shift + P), type and select “Preferences: Open Settings (JSON)”. Copy and append the content below and save the settings.json file.
"azure-iot-edge.platforms": { "amd64": [], "arm32v7": [], "windows-amd64": [], "arm64v8": [], }, "azure-iot-edge.version.csharpmodule": "3.0.0-alpha"
- Create a new C# solution project as usual.
- In Visual Studio Code, select View > Command Palette to open the VS Code command palette.
- In the command palette, enter and run the command Azure: Sign in and follow the instructions to sign in your Azure account. If you’re already signed in, you can skip this step.
- In the command palette, enter and run the command Azure IoT Edge: New IoT Edge solution. Follow the prompts in the command palette to create your solution. For more details of each of the field, please see Create a module project
- Select your target architecture. Open the command palette and search for Azure IoT Edge: Set Default Target Platform for Edge Solution, or select the shortcut icon in the side bar at the bottom of the window. In the promoted window, select arm64v8.
- Build and push your module as usual.
- Deploy the custom module to your ARM64 IoT Edge device.
Debug ARM64 custom module
After you switch to arm64v8 as the platform setting in VS Code, you might be noticed there is no debug version of Dockerfile.arm64v8. This means that currently remote debugging is not supported in ARM64 .net core container (Github issue). However, we can still do local debugging in VS Code without container. What we need to do is to make sure you have the correct configurations in launch.json with .Net Core 3.0 and then follow the local debugging instructions.
ARM64 Preview Template Settings in VS Code
In the first section, we added two settings to enable arm64 experience in VS Code. The first setting ‘platforms’ enables new platform option in status bar, and when select ‘arm64v8’, VS Code can help map the new dockerfile in each module when build Docker images. The second setting help VS Code point to a new template branch or package. So that during project creation, VS Code will read this setting and get the exact template for you. Here comes the list of preview templates or language specific steps.
C# ARM64 preview template
"azure-iot-edge.version.csharpmodule": "3.0.0-alpha"
C ARM64 preview template
"azure-iot-edge.version.cmodule": "arm64-preview"
Node.JS ARM64 preview template
- Install the preview npm package that contains IoT Edge Node.js arm64 template.
npm i -g https://github.com/Azure/generator-azure-iot-edge-module/archive/v1.5.0-arm64-preview.tar.gz
- Create a Node.js module as usual in VS Code.
Java ARM64 preview template
- Install the preview mvn package that contains IoT Edge Java arm64 template.
mvn install:install-file "-Dfile=azure-iot-edge-archetype-1.3.0-arm64-preview.jar" "-DgroupId=com.microsoft.azure" "-DartifactId=azure-iot-edge-archetype" "-Dversion=1.3.0-arm64-preview" "-Dpackaging=jar"
- Update VS Code IoT Edge extension setting.
"azure-iot-edge.version.javamodule": "1.3.0-arm64-preview"
- Create a Java module as usual.
Python ARM64 preview template
We are moving IoT Edge developers to the v2.0.0 of the Azure IoT SDKs for Python. To build and debug arm64 Python module, please follow the steps below.
- Make sure your Python version >= 3.6.6
- Update iotedgehubdev, make sure the version >= 0.11.0
- Install Python v2 SDK on your development machine
pip install azure-iot-device~=2.0.0RC11
- Update VS Code IoT Edge extension setting.
"azure-iot-edge.version.pythonmodule": "arm64-preview"
- Create a Java module as usual.
If you have any questions or feedback, send us email! vsciet at microsoft.com.
0 comments