IoTEdge Module Direct Methods Over Debugging/Simulator - Is it Possible? - azure-iot-hub

I'm developing a multi module scenario using IoTEdge and I need to test Direct Methods Communication using the development environment (Debugging/Simulator).
I've tested the following scenario:
Scenario:
Device1
Module1 - Subscribes SetMethodHandlerAsync (Method1)
Module2 - Calls InvokeMethodAsync (Device1, Module1, Method1)
Results:
It was impossible to reach the destination module due the missing device registration
{"message":"Client rramalho-device not found"} not registered
There is any way to debug direct methods communication without pushing modules to Cloud and having the device running directly in the device ?

You can either simulate a device to debug solutions with multiple modules or simulate a single module application.
A new setting in Azure IoT Tools that enables injection of environment settings into the Visual Studio Code command palette and Azure IoT Edge terminals, you can now build and debug modules on remote devices.
For more information refer this official documentation

Related

How to get the Deployment method in Azure for Self-Hosted Integration runtime?

I want to get the deployment method using Powershell for Self-Hosted Integration Runtime.
The requirement is to track whether the SHIR is installed using "Powershell" commands Or its done through the Azure Portal by a human user by manual steps.
Is there any Flag in Azure which indicates the method of the resource deployment? i.e. if its a PowerShell/ARM template/Portal deployment?
Self-Hosted Integration runtime is a service installed on a windows operating machine (the only OS supported now) either on cloud(VM) or on-prem. Closest you can get to its details is under Applications and Services Logs on system Event Viewer, here you can Filter Logs for timestamp between Start and End of your ADF Pipeline.
Additionally, if you feel this is not helpful, you can share your Feedback so the product team can look into this idea. ✌

Azure IoT Edge Module Twin Settings Set to Empty

I have a number of devices deployed with edge modules running on them. I created a deployment in Azure Portal that targets all devices which sets the environment variables and docker settings. The deployment does not set the twin settings.
I then went into the Azure portal, clicked on the individual devices, clicked "Set modules" and set specific twin module settings for each device.
The problem now is after a period of time some of the devices are receiving an transient network error to Azure Hub which causes them to reload the module twin configuration, however some of the devices load a totally empty twin config, It will continue to periodic auto refresh twin settings with the empty twin settings. If i restart the iotedge service it refreshes the twins and will pull down the correct twin config again and continue to run as expected for a period.
This is a major issue because the modules are basically hung until I log in and manually restart the iotedge service.
Is this the correct way to configure edge modules? or am I missing something?
Thanks
After reading the following post it appears we did not properly implement a handler for twin patches. I think the edge runtime calling the twin update hook with no properties after a connection interruption is a bug however we were able to write logic to handle it based on the examples provided in the post.
https://github.com/Azure/iotedge/issues/1654#issuecomment-551258642

IoT Hub emulator? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Is there an emulator or any suggestions for setting up developer environments with IoT Hub. Having a single IoT Hub in our dev environment shared by all our developers is problematic because messages from each developer are handled by all developers. Setting up unique IoT Hub instances for each developer is also problematic because of the local configuration changes required to connect to each IoT Hub.
An Emulator would be AWESOME! but if that's not available some other way to segregate traffic per developer would be extremely useful.
Regards,
Eli
I'm afraid there's no Azure IoT Hub emulator yet.
If by emulator, you're talking about something like a local server and keeps all the storage in the local RAM or HDD, this might sound like a good idea.
However, when you think about it, it's no easy task for such emulator. Under the hood, we're talking about multiple communication protocol support(http, mqtt, ampq, etc), custom gateway support and seamless integration with other Azure offerings like Stream Analytics, etc...
Not saying it's impossible, but it's complicated.
Anyway, if you want to keep away from receiving unwanted messages from IoT Hub, there's some workaround you can try for now. For example, with mqtt protocol, you can subscribe to some so-called "topic", identified by unique "device id".
If you look forward to having a minimum IoT Hub emulator, go ahead an open up a request in the Azure IoT Hub user voices.
There are few solutions to ease contention when using a single hub. Here are two suggestions:
(Recommended) Unit testing - instead of relying on live data and connecting to a real hub structure your code in a way that you can debug and test it using test input. It usually requires only one layer or separation. For example: http_trigger_azure_function calling a piece of code that can be called from a unit test.
If you structure your code this way the Iot Hub specific code should be minimal.
When using a shared hub you could use custom routes so that only telemetry from developer A's devices goes to developer A's consumer.
Official Azure IoT EdgeHub Dev Tool
The Azure IoT EdgeHub Dev Tool provides a local development experience with a simulator for creating, developing, testing, running, and debugging Azure IoT Edge modules and solutions.
The simulator allows you to run, test and debug your own custom IoT Edge modules locally, without the IoT Edge Runtime, and with the following benefits:
Your custom Edge module code is the same whether running on the simulator or the full IoT Edge Runtime.
Your Edge solution can be run locally without the need to push new images or create IoT Edge deployment manifests.
The only credential required to run your Edge solution on the simulator is the IoT Edge Device Connection String. The IoT Hub Connection String is not needed.
It helps you debug your custom Edge modules on the host and not just in the container.
The following table compares the requirements to run your solution on the IoT Edge Runtime and iotedgehubdev tool:
IoT Edge Runtime
iotedgehubdev
Device Credential Needed
YES
YES
IoT Hub Credential Needed
YES
NO
Build Image
YES
YES
Push Image
YES
NO
Create Deployment
YES
NO
Support native debug scenario
NO
YES
Installing
Install Docker CE (18.02.0+) on
Windows, macOS or Linux
Install Docker Compose (1.20.0+) (Linux only. Compose has already been included in Windows/macOS Docker CE installation)
Install Python (2.7/3.5/3.6/3.7/3.8) and Pip
Install iotedgehubdev by running the following command in your terminal:
pip install --upgrade iotedgehubdev
Note: Please install iotedgehubdev to root on Linux/macOS (Don't use '--user' option in the 'pip install' command).
Please make sure there is no Azure IoT Edge runtime running on the same machine as iotedgehubdev since they require the same ports.
Quickstart
1. Setup
Windows
iotedgehubdev setup -c "<edge-device-connection-string>"
Linux/macOS
sudo iotedgehubdev setup -c "<edge-device-connection-string>"
2. Start/Stop an IoT Edge solution in simulator
Windows
iotedgehubdev start -d <path/to/deployment-manifest>
iotedgehubdev stop
Linux/macOS
sudo iotedgehubdev start -d <path/to/deployment-manifest>
sudo iotedgehubdev stop
3. Start and debug a single module natively
Start the module with specific input(s) and/or environment variable(s)
Windows
iotedgehubdev start -i "<module-inputs>"
// OR
iotedgehubdev start -i "<module-inputs>" -e "<environment-variable>"
Linux/macOS
sudo iotedgehubdev start -i "<module-inputs>"
// OR
sudo iotedgehubdev start -i "<module-inputs>" -e "<environment-variable>"
For example:
iotedgehubdev start -i "input1,input2" -e "TestEnv1=Value1" -e "TestEnv2=Value2"
Output the module credential environment variables
iotedgehubdev modulecred
Start your module natively with the environment variables from the previous step
Send a message to your module through the RESTful API
For example:
curl --header "Content-Type: application/json" --request POST --data '{"inputName": "input1","data": "hello world"}' http://localhost:53000/api/v1/messages
Stop the simulator
Windows
iotedgehubdev stop
Linux/macOS
sudo iotedgehubdev stop
Other resources
Azure IoT Edge for Visual Studio Code
Azure IoT Edge Dev CLI Tool
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 change your telemetry settings by updating collect_telemetry to no in the ini file.
Concerns
While our friend commented he is worried the official link changes, I am hoping the official Microsoft's repo link on GitHub never changes (unless while it still useful). At least, I dont know how other way I can post binary files here.
Here is the repo https://github.com/Azure/iotedgehubdev
Cheers To everyone

MobileFirst application not using deployed adapter, attempting to use development server adapter instead

I'm running MobileFirst 7.0 on a Liberty installation.
Having successfully deployed my application and adapter into the runtime, the preview, when run from the servers operations console, is apparently trying to communicate with the adapter from the development server rather than the one running on Liberty.
[/MaximoMobile/apps/services/api/PhyCount/common/query] failure. state: 404, response: undefined
The runtime on the server is not called MaximoMobile, that is just the name of the project within Eclipse. It shouldn't be being referenced at all outside of the local copy of Mobilefirst.
I've looked up documentation in instructing the application to use the deployment server rather than the development server using JNDI entries in the server.xml file (http://www-01.ibm.com/support/knowledgecenter/SSHSCD_6.3.0/com.ibm.worklight.deploy.doc/admin/t_using_JNDI_lookup_to_override_WL_properties.html), but I can't see anything incorrectly set, or anything even relating to the adapter.
I have managed to set the endpoint to /worklight as required using Eclipse, but it's still returning 404 and attempting to access a non-existent file.
Answering my own question for people who may later stumble upon this looking for an answer:
The preview on the server doesn't work in the same way as the local preview does, and any part of the interface that requires an adapter won't function.
If you need to test the connection to the server, deploying to a device will allow you to do so!

Cross platform desktop development

I would like to develop a cross platform (Linux/Windows) desktop service.
This service needs to run a local HTTP server and needs to have access to a local DB.
It doesn't have any GUI components though.
Also I need to be able to create an installer for both Linux and Windows.
What is the best language/framework/SDK to build such service ?
Java could be perfect for this but I'm not sure there is a decent installer builder out there.
10x
Gilad
Have you considered the Dlib C++ Library found at http://dlib.net/? It includes "A simple HTTP server object you can use to embed a web server into your applications."
As for an installer, perhaps you should consult the following resource: http://en.wikipedia.org/wiki/List_of_installation_software#Cross-platform.