[duplicate] ELMS: how to save module logs to blob storage?

Mistyron 25 Reputation points
2024-11-27T10:35:17.35+00:00

please cross-refer to this post: https://learn.microsoft.com/en-us/answers/questions/2123832/elms-how-to-save-module-logs-to-blob-storage

I apologize for the troubles, I had connectivity issues with the forum.

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
581 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,220 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 33,951 Reputation points MVP
    2024-11-27T18:37:30.1033333+00:00

    Hello @Mistyron ,

    welcome to this moderated Azure community forum.

    The supportbundle call is basically just a way to execute a number of direct methods on the edge agent module.

    As seen in this post, you first need to call 'UploadSupportBundle', follow by one or more 'GetTaskStatus' calls until you get the response with status 'completed'.

    I'm not sure what ELMS is but you can use code to trigger direct methods using the IoT Hub Service SDK.

    This could be done using eg. an Azure Function.

    Based on this sample, I created this (untested) C# code:

    private static async Task InvokeMethodAsync(string deviceId, ServiceClient serviceClient)
    {
        var methodInvocation = new CloudToDeviceMethod("UploadSupportBundle")
        {
            ResponseTimeout = TimeSpan.FromSeconds(30),
        };
        methodInvocation.SetPayloadJson("[THE DEFAULT PAYLOAD OF THE UploadSupportBundle CALL]");
    
        Console.WriteLine($"Invoking direct method for EdgeAgent on device: {deviceId}");
    
        // Invoke the direct method asynchronously and get the response from the simulated device.
        CloudToDeviceMethodResult response = await serviceClient.InvokeDeviceMethodAsync(deviceId, "edgeAgent", methodInvocation);
    
        Console.WriteLine($"Response status: {response.Status}, payload:\n\t{response.GetPayloadAsJson()}");
    }
    
    

    You make use of this Nuget package (or a more recent one):

        <PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" />
    
    

    Make use of the connection string of the IoT Hub, not the device (and keep it secure).

    Notice that you still need to fill in the right payload for this call.

    Notice also that next to the device name, the module name can be passed on (great for modules on edge devices).

    I'm also not sure if the 'edgeAgent' is correct, please try '$edgeAgent' too.

    This should give you a good starting point.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.