Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
580 stars 738 forks source link

Required ENV variables for C Iot Edge Module #2613

Closed tcochunk closed 2 months ago

tcochunk commented 2 months ago

I am pretty new to IOT development and VERY new to C development, so this may be an ignorant question. I am trying to create a very basic C based IOT module to give a co-worker as a sample/POC. I ma trying to create the solution in VS Code because that is what they use but i typically use Visual Studio for my c# development.

I followed the instructions here.

To reduce complexity and help debugging, I am using docker to pull and run the images on a raspberry pi (taking azure module deployment out of the picture). Once i did that, i am getting messages about Environment Variables not specified (no idea how there is a beginner tutorial that doesn't say anything about needing ENV variables). It looks like the following line is trying to get the ENV values (but i am VERY new to C so maybe not):

else if ((iotHubModuleClientHandle = IoTHubModuleClient_LL_CreateFromEnvironment (MQTT_Protocol)) == NULL)

in the IoTHubModuleClient_LL_CreateFromEnvironment method call.

From googling and the error messages, I think these are the values I need:

IOTEDGE_MODULEID - from azure IOTEDGE_DEVICEID - from azure IOTEDGE_IOTHUBHOSTNAME - from azure IOTEDGE_MODULEGENERATIONID - no idea IOTEDGE_GATEWAYHOSTNAME - hostname of host IOTEDGE_APIVERSION - not sure what this should be IOTEDGE_WORKLOADURI - no idea

I have 2 questions:

  1. Is this the correct list of required ENV variables?
  2. Where do i get these values, specifically: IOTEDGE_MODULEGENERATIONID, IOTEDGE_APIVERSION, IOTEDGE_WORKLOADURI

Thank you for your assistance.

ewertons commented 2 months ago

Hi @tcochunk , these are the variables the azure-iot-sdk-c require for using *CreateFromEnvironment(): https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/src/iothub_client_core_ll.c#L160 https://github.com/Azure/azure-iot-sdk-c/blob/main/provisioning_client/adapters/hsm_client_http_edge.c#L46

Are you hitting any of these issues by any chance? https://stackoverflow.com/questions/59847753/getting-iotedge-workloaduri-is-required-exception-while-debugging-iot-edge-so

https://github.com/Azure/iotedge/issues/584

ewertons commented 2 months ago

Hi @tcochunk , we will close this issue for now, but please feel free to reopen it if you would like to follow up. Thanks, Azure IoT SDKs Team.