1

I followed the Microsoft docs for deploying a storage account edge module and my module is currently running in my VM. However, I cannot connect the Python SDK or the storage explorer to it.

My container create options are:

{
"Env": [
    "localstorage",
    "92RhvUXR59Aa8h90LSHC7w=="
],
"HostConfig": {
    "Binds": [
        "blobvolume:/blobroot"
    ],
    "PortBindings": {
        "11002/tcp": [
            {
                "HostPort": "11002"
            }
        ]
    }
}
}

My module twin settings are

{
"deviceAutoDeleteProperties": {
    "deleteOn": false,
    "deleteAfterMinutes": 0,
    "retainWhileUploading": true
},
"deviceToCloudUploadProperties": {
    "uploadOn": true,
    "uploadOrder": "OldestFirst",
    "cloudStorageConnectionString": "<<my connection string was here :) >>",
    "storageContainersForUpload": {
        "eds-container-pcu": {
            "target": "eds-container-pcu"
        }
    },
    "deleteAfterUpload": true
}
}

iotedge list says

blobstorage      running          Up 5 hours       mcr.microsoft.com/azure-blob-storage:latest

I also checked the volume. I put a file into the "BlockBlob" folder in my volume and then I went into the shell of my container and under /blobroot I could find that file.

I also copied the cloud storage connection string and used that for a file upload and that also worked. I could upload a text file into my cloud storage account successfully.

My connection string for my local storage account would be that, no? I created it by myself like the docs said:

DefaultEndpointsProtocol=http;BlobEndpoint=http://localhost:11002/localstorage;AccountName=localstorage;AccountKey=92RhvUXR59Aa8h90LSHC7w==;

With that connection string I cannot connect anything. Not the SDK, nor the Storage Explorer.

Python code would be:

    CONNECTION_STRING = "DefaultEndpointsProtocol=http;BlobEndpoint=http://localhost:11002/localstorage;AccountName=localstorage;AccountKey=92RhvUXR59Aa8h90LSHC7w==;"
    blobClient = BlobClient.from_connection_string(CONNECTION_STRING, "eds-container-pcu", "test123.txt")
    # Doesn't work with or without this line
    blobClient._X_MS_VERSION = '2017-04-17'
    blobClient.upload_blob(data="Hello World", blob_type="BlockBlob")

And I get:

HttpResponseError: Server encountered an internal error. Please try again after some time.
RequestId:fef9066d-323c-47e3-8e6f-ba006557ee65
Time:2021-04-08T14:33:23.7892893Z
ErrorCode:InternalError
Error:None
ExceptionDetails:None
ExceptionMessage:'s' cannot be null
StackTrace:AsyncHelper.ArgumentNullRethrowableException: 's' cannot be null
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at System.Convert.FromBase64String(String s)
   at Microsoft.AzureStack.Services.Storage.FrontEnd.WossProvider.WStorageAccount..ctor(WStorageStamp stamp, String accountName)
   at Microsoft.AzureStack.Services.Storage.FrontEnd.WossProvider.WStorageStamp.Microsoft.Cis.Services.Nephos.Common.Storage.IStorageStamp.CreateAccountInstance(String accountName, ITableServerCommandFactory tableServerCommandFactory)
   at Microsoft.Cis.Services.Nephos.Common.Storage.PerRequestStorageManager.CreateAccountInstance(String accountName)
   at Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.BasicHttpProcessorWithAuthAndAccountContainer`1.GetResourceAccountPropertiesImpl(String accountName, Boolean isAdminAccess, TimeSpan timeout, AsyncIteratorContext`1 context)+MoveNext()
   at AsyncHelper.AsyncIteratorContextBase.ExecuteIterator(Boolean inBegin)
   --- End of inner exception stack trace ---
   at Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.BasicHttpProcessorWithAuthAndAccountContainer`1.EndGetResourceAccountProperties(IAsyncResult asyncResult)
   at Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.BasicHttpProcessorWithAuthAndAccountContainer`1.ProcessImpl(AsyncIteratorContext`1 async)+MoveNext()

Why could that be? Storage explorer is also not connecting and the lines of code above are working fine with my cloud storage connection string.

Andre
  • 103
  • 1
  • 10

2 Answers2

1

A colleague pointed out that my local account key is too short. As written in the docs, the key must have a length of 64 bytes. Connection with SDK or StorageExplorer is fine then. My code also was missing the creation of a local container but the error message will tell about this.

Andre
  • 103
  • 1
  • 10
0

in your sample for the container create options, I am missing the keys (LOCAL_STORAGE_ACCOUNT_NAME and LOCAL_STORAGE_ACCOUNT_KEY). Did you specify only the values?

"Env": [
    "LOCAL_STORAGE_ACCOUNT_NAME=localstorage",
    "LOCAL_STORAGE_ACCOUNT_KEY=92RhvUXR59Aa8h90LSHC7w=="
  ],

When I deploy a module with the settings, I can connect via Storage Explorer.

Did you look at the logs of the blob storage module?

René
  • 151
  • 7