Code Monkey home page Code Monkey logo

vscode-azure-iot-edge's Introduction

Azure IoT Edge for Visual Studio Code

Gitter

Announcement

The Azure IoT Visual Studio Code extension is in a maintenance mode. Please see this announcement for more details. We recommend using the command line steps to develop edge modules over VSCode extensions.

Overview

Azure IoT Edge extension makes it easy to code, build, deploy, and debug your IoT Edge solutions in Visual Studio Code, by providing a rich set of functionalities:

  • Create new IoT Edge solution
  • Add new IoT Edge module to Edge solution
  • Build and publish IoT Edge modules
  • Debug IoT Edge modules locally and remotely
  • IntelliSense and code snippets for the deployment manifest
  • Manage IoT Edge devices and modules in IoT Hub (with Azure IoT Toolkit)
  • Deploy IoT solutions to IoT Edge devices

Added

What's New (v1.25.11)

  • Update default Edge runtime version to 1.4 LTS

What's New (v1.25.10)

  • Snap to the latest simulator version 0.14.18

What's New (v1.25.9)

  • Snap to the latest simulator version 0.14.14

What's New (v1.25.8)

  • Snap to the latest simulator version 0.14.12

What's New (v1.25.0)

  • Generate Dev Container definition files with new Edge Solutions.
  • Ability to add Dev Container definition files to existing Edge Solutions.

What's New (v1.22.0)

Changed

  • Allow user to select deployment template when add module
  • Adopt VS Code's 'asWebviewUri' API

Known Issues

Prerequisites for Azure IoT Edge extension

You need to install prerequisites below to make Azure IoT Edge extension work:

Prerequisites for specific language

To develop IoT Edge modules you also need to install following prerequisites for specific language:

C# module prerequisites

C# Functions on IoT Edge prerequisites

Python module prerequisites

Node.js module prerequisites

Java module prerequisites

C module prerequisites

Quickstart

Click the links below to learn how to develop, debug and deploy IoT Edge modules.

FAQ

Q: All too often, I forget to save a config file, and when I build the docker image. Can we auto-save files before build?

A: By default, VS Code requires an explicit action to save your changes to disk, Ctrl+S. However, it's easy to turn on Auto Save

Q: How to work with Python virtual environment?

A: The Python extension manages your virtual environments in the workspace folder. Please refer to Environments and Automatic Activation of Environments in the Terminal for details.

Q: Help me understand IoT Edge deployment manifest.

A: Learn how to use deployment manifests to deploy modules and establish routes

Q: If I run this extension on Linux (e.g. Ubuntu), when executing docker commands (e.g. the Build IoT Edge Module Image command), the terminal shows permission denied errors. How can I fix this, and avoid having to prefix every command manually with sudo?

A: This extension assumes the current user has sufficient privileges to run docker commands. On Linux you can add the current user to the docker group by executing the following commands:

  • To create the group: sudo groupadd docker
  • To add the current user to it: sudo usermod -aG docker $USER

After executing these commands exit your Terminal session and restart Docker (sudo systemctl restart docker). Or you can reboot the machine completely. Check the Post-installation steps for Linux in the Docker documentation for more information on how to manage Docker as a non-root user.

Commands

Press F1 or Ctrl + Shift + P to open command palette, type Azure IoT Edge: to see all the commands:

  • Azure IoT Edge: New IoT Edge Solution: Create an IoT Edge solution.
  • Azure IoT Edge: Add IoT Edge Module: Add a new IoT Edge module to the IoT Edge solution.
  • Azure IoT Edge: Build IoT Edge Module Image: Containerize IoT Edge module from source code.
  • Azure IoT Edge: Build and Push IoT Edge Module Image: Containerize and push IoT Edge module image to a Docker registry.
  • Azure IoT Edge: Build IoT Edge Solution: Build all the IoT Edge module image in the solution and expand deployment manifest.
  • Azure IoT Edge: Build and Push IoT Edge Solution: Build and push all the IoT Edge module image in the solution and expand deployment manifest.
  • Azure IoT Edge: Setup IoT Edge Simulator: Setup IoT Edge Simulator with an edge device connection string.
  • Azure IoT Edge: Build and Run IoT Edge Solution in Simulator: Build all the IoT Edge module image in the solution and expand deployment manifest. Then run the solution in IoT Edge Simulator.
  • Azure IoT Edge: Run IoT Edge Solution in Simulator: Run the solution of the given deployment manifest in IoT Edge Simulator.
  • Azure IoT Edge: Start IoT Edge Hub Simulator for Single Module: Start the IoT Edge Simulator for testing single module. It will ask for the input names of the module.
  • Azure IoT Edge: Stop IoT Edge Simulator: Stop IoT Edge Simulator.
  • Azure IoT Edge: Set Module Credentials to User Settings: Set the module credential into "azure-iot-edge.EdgeHubConnectionString" and "azure-iot-edge.EdgeModuleCACertificateFile" in user settings. The credentials could be used to connect IoT Edge Simulator.
  • Azure IoT Edge: Create deployment for Edge device: Create and submit the deployment to your IoT Edge device with specified deployment manifest.

You can also trigger following frequently-used commands in context menu.

  • Azure IoT Edge: Add IoT Edge Module: The context menu of deployment.template.json file or modules folder in VS Code file explorer. A new module will be added to the modules folder.
  • Azure IoT Edge: Build IoT Edge Solution: The context menu of deployment.template.json file in VS Code file explorer.
  • Azure IoT Edge: Build and Push IoT Edge Solution: The context menu of deployment.template.json file in VS Code file explorer.
  • Azure IoT Edge: Build and Run IoT Edge Solution in Simulator: The context menu of deployment.template.json file in VS Code file explorer.
  • Azure IoT Edge: Generate IoT Edge Deployment Manifest: The context menu of deployment.template.json file in VS Code file explorer. The deployment manifest (deployment.json) will be expanded from deployment.template.json.
  • Azure IoT Edge: Build IoT Edge Module Image: The context menu of the module.json file in VS Code file explorer. With the input platform from user, it will build the image with the target Dockerfile.
  • Azure IoT Edge: Build and Push IoT Edge Module Image: The context menu of the module.json file in VS Code file explorer. With the input platform from user, it will build and push image with the target Dockerfile.
  • Azure IoT Edge: Create deployment for Edge device: The context menu of an IoT Edge device in device list. Create a deployment for target IoT Edge device with deployment manifest file you select.
  • Azure IoT Edge: Edit module twin: The context menu of a deployed module in device list. Fetch target module twin and then update it in edit view.

Code Snippets

Trigger Content
edgeModule Add IoT Edge module in IoT Edge deployment manifest
edgeRoute Add IoT Edge route in IoT Edge deployment manifest

Resources

Supported Operating Systems

Currently this extension supports the following operating systems:

  • Windows 7 and later (32-bit and 64-bit)
  • macOS 10.10 and later
  • Ubuntu 16.04

The extension might work on other Linux distros as some users have reported, but be aware that Microsoft provides no guarantee or support for such installations. You can find Azure IoT Edge support here.

TypeEdge (Experimental)

The Azure IoT TypeEdge introduces a strongly-typed flavor of the inherently loosely coupled vanilla Azure IoT Edge. We would like to invite you to try TypeEdge out and give us any feedback or recommendations you might have here. TypeEdge is still an experimental project that we don’t recommend to use it in production IoT Edge project.

To get started, please visit the project repo and give us feedback via Github Issues.

Data/Telemetry

This project collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more. If you don’t wish to send usage data to Microsoft, you can set the telemetry.enableTelemetry setting to false. Learn more in our FAQ.

Support and Contact Us

You can join in our Gitter to ask for help, report issues and talk to the product team directly.

vscode-azure-iot-edge's People

Contributors

adashen avatar blackchoey avatar c-ryan-k avatar dependabot[bot] avatar eriolchan avatar formulahendry avatar jantielens avatar konichi3 avatar lazarusx avatar marianan avatar mhshami01 avatar michaeljqzq avatar microsoft-github-policy-service[bot] avatar sldragon avatar timmyreilly avatar vikas0212git avatar williamberryiii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-azure-iot-edge's Issues

[Add IoT Edge Module]update the launch.json file failed.

steps:
1.create new IoT Edge solution
2.Add 1 C# Edge Module
3.delete the launch.json in your .vscode folder
4.press F5 and select IoT Edge (.NER Core).
verify launch.json is generated.
5. Add another C# Edge Module
verify the module was created successfully, but get an error when updated launch.json file. the new module was not added in launch.json.

image

image

Docker issues in bugbash

OS: Microsoft Windows [Version 10.0.16299.248]

Docker Version:

Version 17.12.0-ce-win47 (15139)
Channel: stable
9c692cd

Inner Loop in VS Code

Optimized C# module experience

Raw logs:

bugbash.log

Dockerfile.amd64.debug improvements

The current Dockerfile.amd64.debug causes significantly longer rebuild times than necessary, and requires significantly more bytes to be pushed due to Docker layer changes. With the changes below, a trivial C# Module on rebuild only needs to push ~10MB instead of 170MB+, and rebuilds are faster since the vsdbg layer is cached. The main issue is vsdbg is installed as one of the last steps, when it should be installed as one of the first steps.

Current Dockerfile.amd64.debug template:

FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Debug -o out

FROM microsoft/dotnet:2.0-runtime-stretch AS runtime
WORKDIR /app
COPY --from=build-env /app/out ./

RUN apt-get update
RUN apt-get install -y unzip procps
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg

ENTRYPOINT ["dotnet", "echo-service.dll"]

Improved Dockerfile.amd64.debug template:

FROM microsoft/dotnet:2.0-runtime-stretch AS runtime

RUN apt-get update
RUN apt-get install -y unzip procps
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg

FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Debug -o out

FROM runtime
WORKDIR /app
COPY --from=build-env /app/out ./

ENTRYPOINT ["dotnet", "echo-service.dll"]

deployment.template.json and launch.json are still updated if there is error in create module

  1. install the released function template (to test the legacy template)
  2. Select deployment.template.json to add module
  3. Use C# function module type
  4. Error shows since there is no "-r" option in legacy template
  5. Check the deployment.template.json and launch.json, however, they are both updated.

Desired:
if new module failed, deployment.template.json and launch.json should not be updated

[Debug Edge Module] Can't debug module.

steps:
1.create a new IoT Edge solution (c# Module)
2.add 3 IoT Edge Module
3.Build IoT Edge Solution
4.Deploy Edge Device
5.Setup and start Edge runtime
6.Debug Edge Module
Navigate to debug view, and select “Debug IoT Edge Module SampleModule (.NET Core)”, then press F5
get error :
Executing: docker exec -i SampleModule sh -c "sh -s" < C:\Users\v-czg.vscode\extensions\ms-vscode.csharp-1.14.0\scripts\remoteProcessPickerScript
Linux
stderr: sh: 1: ps: not found
Error Message: Command failed: docker exec -i SampleModule sh -c "sh -s" < C:\Users\v-czg.vscode\extensions\ms-vscode.csharp-1.14.0\scripts\remoteProcessPickerScript
sh: 1: ps: not found

image

debug Python Module failed

  1. New IoT Edge solution
  2. Add Python Module
  3. build and push the Iot edge image
    4.Generate IoT Edge Deployment Manifest
    image
  4. Create deployment for Edge device
    6.Setup and start Edge runtime
    7.Debug Edge Module
    there is an error:
    Unable to open 'DotNetFunctionInvoker.cs': File not found (file:///home/ahmed/repos/azure-webjobs-sdk-script/src/WebJobs.Script/Description/DotNet/DotNetFunctionInvoker.cs).

image

[doc improvement] optional prerequisites

In the Prerequisites, Python extension for Visual Studio Code is optional, not required. Better to make it be:

[Optional] Python extension for Visual Studio Code

docker push image failed due to not start a local registry

Right-click the deployment.template.json file, and click Build IoT Edge Solution
verify all the modules are built ,but pushed failed
image

because user not start a local registry:  docker run -d -p 5000:5000 --name registry registry:2 

but in our tool , Did not tell the user to register it.

[IoT Edge Solution] Deployment template/Build Solution support for platforms

The name 'deployment.template.json' is hard-coded for the 'Generate IoT Edge Deployment Manifest' command. There are significant differences when building arm32v7 (e.g. the container images for systemModules are different, plus all my module images). It would be nice to support platforms:

[1] 'Generate IoT Edge Deployment Manifest' and 'Build IoT Edge Solution' should have a parameter to pick which platform to build from the same set in module.json (amd64/amd64.debug/arm32v7/windows-amd64), which is filled in as a parameter in the deployment.template.json - ${MODULES..PLATFORM}

[Create Edge Device] Create edge device failure when named edgeDeviceC#

Steps:
1.press F1 and select Edge:create Edge Device
2.input device ID named edgeDeviceC#
verify there is an error as bellow.

[Edge Device] Creating Edge Device 'edgeDeviceC#'
[Edge Device] [Create] error: ArgumentError: Error:

<TITLE>Bad Request</TITLE>

Bad Request - Invalid URL


HTTP Error 400. The request URL is invalid.

image

Add support for custom Docker arguments in module.json

ISSUE
Some Dockerfiles require additional arguments to build correctly. For example, some may require Environment variables or other arbitrary Docker arguments (--add-host). Right now, the docker build command only supports custom image tags:
https://github.com/Microsoft/vscode-azure-iot-edge/blob/master/src/container/containerManager.ts

SOLUTION
Add support in module.json for extra Docker build commands. E.g. add a parameter for docker build arguments:

"docker": {
"build-args": [ "arg1", "arg2" ]
}

Unable to start filter module in Python

Follow the doc : https://review.docs.microsoft.com/en-us/azure/iot-edge/tutorial-python-module?branch=pr-en-us-35471
Got the following error:

Machine temperature 27.0104326896 exceeds threshold 25
Confirmation[0] received for message with result = OK
Properties: {'MessageType': 'Alert'}
Total calls confirmed: 11
Data: <<<{"machine":{"temperature":27.030986996382,"pressure":1.6870744679422534},"ambient":{"temperature":20.770010575312195,"humidity":24},"timeCreated":"2018-03-16T08:34:29.5137673Z"}>>> & Size=177
Properties: {}
Total calls received: 12
Machine temperature 27.0309869964 exceeds threshold 25
Confirmation[0] received for message with result = OK
Properties: {'MessageType': 'Alert'}
Total calls confirmed: 12

Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609]

IoT Hub Client for Python
Adding TrustedCerts from: /mnt/edgemodule/edge-device-ca.cert.pem
set_option TrustedCerts successful
Starting the IoT Hub Python sample using protocol MQTT...
The sample is now waiting for messages and will indefinitely. Press Ctrl-C to exit.
Error: Time:Fri Mar 16 08:45:46 2018 File:/usr/sdk/src/c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:584 Failure: socket state is not closed.
Error: Time:Fri Mar 16 08:45:46 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:on_underlying_io_open_complete Line:751 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO.
Error: Time:Fri Mar 16 08:45:46 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:tlsio_openssl_open Line:1251 Failed opening the underlying I/O.
Error: Time:Fri Mar 16 08:45:46 2018 File:/usr/sdk/src/c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:980 Error: io_open failed
Error: Time:Fri Mar 16 08:45:46 2018 File:/usr/sdk/src/c/iothub_client/src/iothubtransport_mqtt_common.c Func:SendMqttConnectMsg Line:1932 failure connecting to address iverwin10.fareast.corp.microsoft.com.
Error: Time:Fri Mar 16 08:45:48 2018 File:/usr/sdk/src/c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:584 Failure: socket state is not closed.
Error: Time:Fri Mar 16 08:45:48 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:on_underlying_io_open_complete Line:751 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO.
Error: Time:Fri Mar 16 08:45:48 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:tlsio_openssl_open Line:1251 Failed opening the underlying I/O.
Error: Time:Fri Mar 16 08:45:48 2018 File:/usr/sdk/src/c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:980 Error: io_open failed
Error: Time:Fri Mar 16 08:45:48 2018 File:/usr/sdk/src/c/iothub_client/src/iothubtransport_mqtt_common.c Func:SendMqttConnectMsg Line:1932 failure connecting to address iverwin10.fareast.corp.microsoft.com.
Error: Time:Fri Mar 16 08:45:52 2018 File:/usr/sdk/src/c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:584 Failure: socket state is not closed.
Error: Time:Fri Mar 16 08:45:52 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:on_underlying_io_open_complete Line:751 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO.
Error: Time:Fri Mar 16 08:45:52 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:tlsio_openssl_open Line:1251 Failed opening the underlying I/O.
Error: Time:Fri Mar 16 08:45:52 2018 File:/usr/sdk/src/c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:980 Error: io_open failed
Error: Time:Fri Mar 16 08:45:52 2018 File:/usr/sdk/src/c/iothub_client/src/iothubtransport_mqtt_common.c Func:SendMqttConnectMsg Line:1932 failure connecting to address iverwin10.fareast.corp.microsoft.com.
Error: Time:Fri Mar 16 08:46:00 2018 File:/usr/sdk/src/c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:584 Failure: socket state is not closed.
Error: Time:Fri Mar 16 08:46:00 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:on_underlying_io_open_complete Line:751 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO.
Error: Time:Fri Mar 16 08:46:00 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:tlsio_openssl_open Line:1251 Failed opening the underlying I/O.
Error: Time:Fri Mar 16 08:46:00 2018 File:/usr/sdk/src/c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:980 Error: io_open failed

Consider building docker image in the cloud

Setting Docker, downloading Docker components and creating docker image takes a lot of time in my machine.
There is no need to do that work in local if I don't want to do local testing and debugging.
Consider move that part to Azure so that I could submit code only.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.