How to create a local blob storage account container on an IoT Edge device?

Florian Graff 20 Reputation points
2024-01-23T10:27:02.8033333+00:00

Hi everyone! I followed this tutorial: https://learn.microsoft.com/de-de/azure/iot-edge/how-to-deploy-blob I try to regularly upload a single file (SQLite DB) on an IoT Edge device i have connected to my IoT Hub in Azure. On the edge device I installed the module "AzureBlobStorageonIoTEdge". In the configuration for this module, you have to name the locale storage container: Module Twin Settings:

{
    "deviceAutoDeleteProperties": {
        "deleteOn": false,
        "deleteAfterMinutes": 10,
        "retainWhileUploading": true
    },
    "deviceToCloudUploadProperties": {
        "uploadOn": true,
        "uploadOrder": "NewestFirst",
        "cloudStorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=edgedevicestorage1;AccountKey=KEY;EndpointSuffix=core.windows.net",
        "storageContainersForUpload": {
            "localstorage1": {
                "target": "edgedevicestorage1container1"
            }
        },
        "deleteAfterUpload": false
    }
}

After deployment to the Edge device I see the following error in the device logs:

[2024-01-23 10:00:43.247] [info    ] [tid 1093] [BlobInterface.cc:1494] [ListBlobsInOrder] ListBlobsInOrder received. Container:localstorage1 BlobNameStart:null MaxBlobNames:1 OrderType:1 Flags:1
[2024-01-23 10:00:43.247] [error   ] [tid 1093] [MetaStore.cc:1953] [ListBlobsInOrder] Container not found. Name:localstorage1
[2024-01-23 10:00:43.247] [error   ] [tid 1093] [BlobInterface.cc:1535] [ListBlobsInOrder] ListBlobsInOrder failed. Container:localstorage1 Error:39987

It says "container not found". But how can i create this 'local' container on the edge device? I found nothing regarding that in the tutorial. I only found some blog posts which say, I have to do it via the Azure Storage Explorer manually, but i cannot connect to my edge storage, because i don't know the name of the local storage account. General Context: I want to upload Button Press information stored in a local SQLite DB on many different iot edge devices to azure in order to collect them all in one big PostgreSQL DB in Azure. And i am currently looking for a viable solution to achieve that. I really appreciate any helpful suggestions!! BR Florian

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.
520 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,282 questions
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 12,276 Reputation points
    2024-01-27T01:38:49.5766667+00:00

    Hi @Florian Graff Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    Looking at the case description I understand that your Azure blob storage module failed to deploy on the IoT Edge device. From the bindings of your container create options, it appears that you are trying to Volume Mount option. Can you run the following command docker volume ls connecting to your IoT Edge device and see the result it returns. If you have a volume mount created, it should be displayed in the returned result. Please find the below image for reference.

    User's image

    If the above command does not return any data, it implies that you have not created a volume mount on your Edge device. You can create a volume mount by executing the following command docker volume create my-vol on your IoT Edge device. You then need to then specify this volume mount in the bind options. Please find the below container create options I have tested on my IoT Edge device.

    {
        "Env": [
            "LOCAL_STORAGE_ACCOUNT_NAME=localstorage",
            "LOCAL_STORAGE_ACCOUNT_KEY=<key>"
        ],
        "HostConfig": {
            "Binds": [
                "localblob:/blobroot"
            ],
            "PortBindings": {
                "11002/tcp": [
                    {
                        "HostPort": "11002"
                    }
                ]
            }
        }
    }
    

    Creating this Volume mount and providing the correct binding should resolve your Container not found error.

    i don't know the name of the local storage account

    Your can find your local storage account name and key information from your container create options. In your case, localstorage1 is the local storage account name.

    Better approach

    Considering you have multiple IoT Edge devices, it would not be ideal to create Edge Blob storage modules on each of your devices. Instead, you can use routing on your IoT Edge modules and push the data to the IoT Hub. You can easily add routes to your modules from Azure portal Set Modules pane of your IoT Edge device. Here is an example of a route that pushes all device to cloud messages from a particular module of Edge device to IoT Hub.

    enter image description here

    You can then use IoT Hub routing to route all this messages to any built-in end point such as Event Hub. If you are flexible with your end point DB, IoT Hub supports Cosmos DB routing out of the box. You can simple follow the steps provided in the following article Routing in IoT Hub

    If you prefer to use PostgreSQL as your final endpoint, you have a few extra configurations that needs to be done.

    1. Route the data received from IoT Hub to an end point such as Event Hub
    2. Create an Azure trigger function to process the events from the end point. Here is an example for Event Hub trigger Azure function
    3. Push the data from the Azure function to your PostgreSQL following the steps provided in the article Connect from Function app with managed identity to Azure Database for PostgreSQL

    Hope this helps! I understand there are lot of configurations need to be done based on the approach you take. Please let us know if you run into any issues implementing the approach.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.


1 additional answer

Sort by: Most helpful
  1. Surbhi 596 Reputation points Microsoft Employee
    2024-01-23T10:40:05.49+00:00

    Hi Florian, While adding the IoT Edge Module did you click on tab "Container Create Options"? User's image

    I followed the same tutorial: https://learn.microsoft.com/de-de/azure/iot-edge/how-to-deploy-blob you shared with me.

    1 person found this answer helpful.