Iotedge: Error 500 IoT Edge module container Image expecting IOTEDGE_WORKLOADURI enviorment variable

Created on 29 Nov 2018  路  6Comments  路  Source: Azure/iotedge

Error 500 at IoT Edge module

The container Image expecting IOTEDGE_WORKLOADURI enviorment variable when trying to run the application in debug mode.

[Module] Module info: {
"moduleId": "WinUDPListener",
"managedBy": "IotEdge",
"deviceId": "vm-win10-edge",
"generationId": "636790063927487363",
"etag": "NjE0NzI1NjM2",
"connectionState": "Disconnected",
"connectionStateUpdatedTime": "0001-01-01T00:00:00",
"lastActivityTime": "0001-01-01T00:00:00",
"cloudToDeviceMessageCount": 0,

Connection State is also disconnected. When tried running the module at the edge runtime envionment using powershell

Unhandled Exception: System.AggregateException: One or more errors occurred. (Environment variable IOTEDGE_WORKLOADURI is required.) ---> System.InvalidOperationException: Environment variable IOTEDGE_WORKLOADURI is required.
at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync()
at UdpListenerModule.Program.Init() in C:appProgram.cs:line 53
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at UdpListenerModule.Program.Main(String[] args) in C:appProgram.cs:line 27

Appreciate your help as setting IOTEDGE_WORKLOADURI environment variable didnt make any difference.

image

image

customer-reported iotedge

Most helpful comment

@prashbv How about some additional detail on how/where you solved this? Which file/section and what did you set it to??

All 6 comments

Can you please provide a little more detail around your scenario? Are these modules being started outside of the context of the IoT Edge? This environment variable is set by the Edge Agent when starting the containers.

Hello Mike,

Thanks for your time in reading out this issue. These Iot edge modules are a customer one built in C# and deployed into the edge runtime both onprem and VM hosted in cloud.

I am not getting the 500 error now and the module is also running. But during its runtime its not able to get the environment variable IOTEDGE_WORKLOADURI although its been configured at the .env file and as well at the within module environment variables section at the azure portal.

image

Appreciate if you have any advise.

This environment variable (IOTEDGE_WORKLOADURI) is set by the runtime itself. It shouldn't need to be set explicitly via the .env file or in the portal.

What version of iotedge is running? You can run iotedge version in the terminal to get the version number.

ISSUE RESOLVED.
For a custom application like C# edge module in my case IOTEDGE_WORKLOADURI i had to configure it into the CreateOptions section which i did earlier but failed due to syntax issues.

Upon defining Createoptions section with required environment variables into deployment template file pushed these into the edge solution config file and was able to be picked up during runtime.

Likewise the same can be configured at the ARM portal within the module when you select through Set Module option.

However the text boxes given to input envionment variables wasnt really working well and i did stay away from that option as working through the application config file was much easier.

Thankyou for your time. Cheers!

@prashbv How about some additional detail on how/where you solved this? Which file/section and what did you set it to??

I solved this by adding:

<ItemGroup>
  <ProjectCapability Include="AzureIoTEdgeModule" />
</ItemGroup>

to the .csproj file

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndyLiTaiwan picture AndyLiTaiwan  路  5Comments

lakshmisivareddy picture lakshmisivareddy  路  3Comments

nhuurnink picture nhuurnink  路  6Comments

arabold picture arabold  路  3Comments

Lexmark-pcarey picture Lexmark-pcarey  路  4Comments