无法连接到本地存储帐户
Can't connect to local storage account
我按照 Microsoft 文档部署存储帐户边缘模块,我的模块目前 运行 在我的 VM 中。
但是,我无法将 Python SDK 或存储资源管理器连接到它。
我的容器创建选项是:
{
"Env": [
"localstorage",
"92RhvUXR59Aa8h90LSHC7w=="
],
"HostConfig": {
"Binds": [
"blobvolume:/blobroot"
],
"PortBindings": {
"11002/tcp": [
{
"HostPort": "11002"
}
]
}
}
}
我的模块孪生设置是
{
"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 列表说
blobstorage running Up 5 hours mcr.microsoft.com/azure-blob-storage:latest
我也查了一下音量。我将一个文件放入我的卷中的“BlockBlob”文件夹,然后我进入我的容器的 shell 并在 /blobroot 下我可以找到该文件。
我还复制了云存储连接字符串并将其用于文件上传并且也有效。我可以成功将文本文件上传到我的云存储帐户。
我的本地存储帐户的连接字符串是这样的,不是吗?正如文档所说,我自己创建了它:
DefaultEndpointsProtocol=http;BlobEndpoint=http://localhost:11002/localstorage;AccountName=localstorage;AccountKey=92RhvUXR59Aa8h90LSHC7w==;
使用那个连接字符串我无法连接任何东西。不是 SDK,也不是存储资源管理器。
Python 代码为:
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")
我得到:
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()
为什么会这样?存储资源管理器也没有连接,上面的代码行与我的云存储连接字符串一起工作正常。
一位同事指出我的本地帐户密钥太短了。如文档中所写,密钥的长度必须为 64 字节。然后与 SDK 或 StorageExplorer 连接就可以了。我的代码也缺少本地容器的创建,但错误消息会说明这一点。
在容器创建选项的示例中,我缺少键(LOCAL_STORAGE_ACCOUNT_NAME 和 LOCAL_STORAGE_ACCOUNT_KEY)。您是否只指定了值?
"Env": [
"LOCAL_STORAGE_ACCOUNT_NAME=localstorage",
"LOCAL_STORAGE_ACCOUNT_KEY=92RhvUXR59Aa8h90LSHC7w=="
],
当我使用设置部署模块时,我可以通过存储资源管理器连接。
您查看 blob 存储模块的日志了吗?
我按照 Microsoft 文档部署存储帐户边缘模块,我的模块目前 运行 在我的 VM 中。 但是,我无法将 Python SDK 或存储资源管理器连接到它。
我的容器创建选项是:
{
"Env": [
"localstorage",
"92RhvUXR59Aa8h90LSHC7w=="
],
"HostConfig": {
"Binds": [
"blobvolume:/blobroot"
],
"PortBindings": {
"11002/tcp": [
{
"HostPort": "11002"
}
]
}
}
}
我的模块孪生设置是
{
"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 列表说
blobstorage running Up 5 hours mcr.microsoft.com/azure-blob-storage:latest
我也查了一下音量。我将一个文件放入我的卷中的“BlockBlob”文件夹,然后我进入我的容器的 shell 并在 /blobroot 下我可以找到该文件。
我还复制了云存储连接字符串并将其用于文件上传并且也有效。我可以成功将文本文件上传到我的云存储帐户。
我的本地存储帐户的连接字符串是这样的,不是吗?正如文档所说,我自己创建了它:
DefaultEndpointsProtocol=http;BlobEndpoint=http://localhost:11002/localstorage;AccountName=localstorage;AccountKey=92RhvUXR59Aa8h90LSHC7w==;
使用那个连接字符串我无法连接任何东西。不是 SDK,也不是存储资源管理器。
Python 代码为:
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")
我得到:
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()
为什么会这样?存储资源管理器也没有连接,上面的代码行与我的云存储连接字符串一起工作正常。
一位同事指出我的本地帐户密钥太短了。如文档中所写,密钥的长度必须为 64 字节。然后与 SDK 或 StorageExplorer 连接就可以了。我的代码也缺少本地容器的创建,但错误消息会说明这一点。
在容器创建选项的示例中,我缺少键(LOCAL_STORAGE_ACCOUNT_NAME 和 LOCAL_STORAGE_ACCOUNT_KEY)。您是否只指定了值?
"Env": [
"LOCAL_STORAGE_ACCOUNT_NAME=localstorage",
"LOCAL_STORAGE_ACCOUNT_KEY=92RhvUXR59Aa8h90LSHC7w=="
],
当我使用设置部署模块时,我可以通过存储资源管理器连接。
您查看 blob 存储模块的日志了吗?