akshata29/entaoai

Azure Blob Storage Upload not working.

Closed this issue · 2 comments

Running locally and then uploading the document does not upload the file to Azure Blob storage.

I modified the following values in the "local.setting.json" file as guided.
"OpenAiDocStorName": "chatspkstor", // Storage name
"OpenAiDocStorKey": "AzureStorageAccount Access Key value", // Storage doc
"OpenAiDocContainer": "chatpdf", // Storage Container

Also modified .env file.
I tried replacing the Connection String with the value generated by the Blob Shared Access Key policy, but it doesn't work the same.

BLOB_CONNECTION_STRING="https://chatspkstor.blob.core.windows.net/" # Name of your Blob connection string where you will upload PDF to
BLOB_CONTAINER_NAME="chatpdf" # Name of your container to host uploaded files

===============================================================================
Traceback (most recent call last):
File "c:\Users\niceysj\repo\chatgptspk\chatpdf\app\backend\app.py", line 234, in uploadBinaryFile
blobServiceClient = BlobServiceClient.from_connection_string(url)
File "C:\Users\niceysj\AppData\Local\Programs\Python\Python39\lib\site-packages\azure\storage\blob_blob_service_client.py", line 181, in from_connection_string account_url, secondary, credential = parse_connection_str(conn_str, credential, 'blob')
File "C:\Users\niceysj\AppData\Local\Programs\Python\Python39\lib\site-packages\azure\storage\blob_shared\base_client.py", line 406, in parse_connection_str
raise ValueError("Connection string missing required connection details.")
ValueError: Connection string missing required connection details.
127.0.0.1 - - [15/Apr/2023 15:21:55] "POST /uploadBinaryFile HTTP/1.1" 500 -
INFO:werkzeug:127.0.0.1 - - [15/Apr/2023 15:21:55] "POST /uploadBinaryFile HTTP/1.1" 500 -
ERROR:root:Exception in /processDoc
Traceback (most recent call last):
File "c:\Users\niceysj\repo\chatgptspk\chatpdf\app\backend\app.py", line 163, in processDoc
jsonDict = json.loads(resp.text)
File "C:\Users\niceysj\AppData\Local\Programs\Python\Python39\lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\niceysj\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\niceysj\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
127.0.0.1 - - [15/Apr/2023 15:21:58] "POST /processDoc HTTP/1.1" 500 -
INFO:werkzeug:127.0.0.1 - - [15/Apr/2023 15:21:58] "POST /processDoc HTTP/1.1" 500 -

Blob connection string needs to be in following format
BLOB_CONNECTION_STRING="DefaultEndpointsProtocol=https;AccountName=YOURACCOUNTNAME;AccountKey=YOURACCOUNTKEY;EndpointSuffix=core.windows.net"

I modified the connection values according to your guide and it worked fine.
Thank you.