Hi - following these instructions how-to-store-data-blob I am trying to set up blob storage on a Raspberry Pi 3B (arm32v7) device running Raspbian GNU/Linux 10 (buster).
I have the storage module up and running and using Azure Storage Explorer version 1.10 (seems to be only version that works with this?) - I can connect, create a container and demonstrate the upload/auto delete functionality ok. The BLOB_CONNECTION_STRING below matches that used in the Azure Storage Explorer.
Using python (3.7.3) I am trying to write to the local storage however and it doesn't appear to work.
Firstly, using the Azure storage 2.1.0 SDK:
import os
from azure.storage.blob import BlockBlobService
BLOB_CONNECTION_STRING = 'DefaultEndpointsProtocol=http;BlobEndPoint=http://<ip address>:11002/<account name>;AccountName=<account name>;AccountKey=<account key>;'
container = 'iot-timing-upload'
try:
bbs = BlockBlobService(connection_string=BLOB_CONNECTION_STRING, endpoint_suffix='',custom_domain='')
except Exception as err:
print(err)
raise
local_path='/Users/chris/racehub/utils'
blob_file_name = 'anon_html.sh'
full_path='/Users/chris/racehub/utils/anon_html.sh'
try:
bbs.create_blob_from_path(
container_name=container, blob_name= blob_file_name, file_path=full_path
)
except Exception as err:
print(err)
This gives the following error on create_blob_from_path:
Client-Request-ID=8b9cfd14-48fe-11eb-a3e4-38c9862ca7cf Retry policy did not allow for a retry: , HTTP status code=Unknown, Exception=HTTPConnectionPool(host='<account name>.blob.core.windows.net', port=80): Max retries exceeded with url: /iot-timing-upload/anon_html.sh (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x106e81a90>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')).
HTTPConnectionPool(host='<account name>.blob.core.windows.net', port=80): Max retries exceeded with url: /iot-timing-upload/anon_html.sh (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x106e81a90>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
I don't really understand why it's looking at blob.core.windows.net as the endpoint suffix is set to '', or why it's looking at port 80.
I also tried using azure-storage-blob 12.6.0:
import os
from azure.storage.blob import BlobServiceClient
BLOB_CONNECTION_STRING = 'DefaultEndpointsProtocol=http;BlobEndPoint=http://<ip address>:11002/<account name>;AccountName=<account name>;AccountKey=<account key>;'
try:
blob_service_client = BlobServiceClient.from_connection_string(BLOB_CONNECTION_STRING)
except Exception as err:
print(err)
raise
container = 'iot-timing-upload'
blob_file_name = 'anon_html.sh'
try:
output_file = blob_service_client.get_blob_client(container = container, blob = blob_file_name)
except Exception as err:
print(err)
raise
full_path='/Users/chris/racehub/utils/anon_html.sh'
try:
with open(full_path, "rb") as data:
output_file.upload_blob(data)
except Exception as err:
print(err)
raise
Which gave the following error:
Traceback (most recent call last):
File "/Users/chris/Library/Python/3.7/lib/python/site-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/Users/chris/Library/Python/3.7/lib/python/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
File "/Users/chris/Library/Python/3.7/lib/python/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
TimeoutError: [Errno 60] Operation timed out
Please could someone advise where I'm going wrong.
Thanks