Interacting with Azure Edge Devices through ThingWorx > Using Azure Device Methods from ThingWorx
Using Azure Device Methods from ThingWorx
The Firmware Update Demo provides a complete example of how to use Device Methods from ThingWorx. When writing an edge application with an Azure Edge Device SDK, include code that handles the Device Methods when they are called as services from ThingWorx. The ThingWorx Azure IoT Hub Connector passes service requests from ThingWorx Platform as Device Methods that run in Azure.
One of the key pieces of information that you need when invoking Device Methods is the connection string for the device. You can go to the Azure portal and navigate to your IoT Hub to find this string. If the connection string contains a semi-colon, you need to put quotation marks around the string. The semi-colon will stop shell commands from executing. The quotation marks can be single if no other single quotation marks are used in the string. Otherwise, use double quotation marks.
The 1.16.1 version of iot-service-client strips the open and close double quotation marks from direct method String payloads (parameters). If you are using this newer version of the iot-service-client, use single quotation marks around a String that contains a semi-colon.
The demo/firmware-update-demo/edge subdirectory contains an example edge application. that, when run against an instance of ThingWorx Platform, illustrates the invocation of Azure Device Methods from ThingWorx. The demo/firmware-update-demo/platform/entities directory contains a file that, when imported into ThingWorx Platform, creates the entities needed for the demo. After creating your own edge application, use ThingWorx Composer (as long as you have imported the extensions) to create an AzureIotThing and add services to it that will invoke Device Methods when the Connector passes the service calls to Azure.