Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Blob Storage Upload not working. #7

Closed
niceysj opened this issue Apr 15, 2023 · 2 comments
Closed

Azure Blob Storage Upload not working. #7

niceysj opened this issue Apr 15, 2023 · 2 comments

Comments

@niceysj
Copy link

niceysj commented Apr 15, 2023

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 -

@akshata29
Copy link
Owner

akshata29 commented Apr 18, 2023

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

@niceysj
Copy link
Author

niceysj commented Apr 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants