NoneType object error related to Blob storage

Mingkai Liu 50 Reputation points

After upgrading my azure functions to runtime to ~4, and python to 3.11, as in my previous post, they seem to run fine. Except one of them shows the below error, seems to be related to Blob storage:User's image

I then roll back to ~2, python 3.7 (it was 3.6 before upgrading), and similar error still occurs.
User's image

Any idea what could be the reason?

Thank you very much!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,219 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,420 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,141 Reputation points

    Mingkai Liu Thanks for sharing the solution in the thread so that it will benefit others experiencing the similar issue. Since the Microsoft Q&A community has a policy that The question author cannot accept their own answer. They can only accept answers by others, I will repost your solution in case you like to accept the answer for greater visibility.


    After upgrading to Python 3.11/V4 version, you have experienced errors: File is not a zip file and cannot unpack non-iterable NoneType object with the following lines of code: (using pandas library)

            # Retrieve the connection string for use with the application.
            connect_str = os.getenv("flpwrenvirogreendata_Connection_Str")
  "Get connection string: {connect_str}")
            # Create the BlobServiceClient object which will be used to create a container client
            blob_service_client = BlobServiceClient.from_connection_string(connect_str)
  "Created blob service client {blob_service_client}")
            # Create a blob client using the file name as the name for the blob
            blob_client = blob_service_client.get_blob_client(container=container_name, blob=file_name)
  "Created blob client {blob_client}")
            # read  file from blob as binary
            downloader = blob_client.download_blob()
  "downloader {downloader }")
            content_byte = downloader.readall()
                #"pyxlsb" "openpyxl"
                dfs = pd.read_excel(downloader.readall(), sheet_name=None, engine="openpyxl") 
      "read excel {type(content_byte)}")        
            except pd.errors.ParserError as e:
                logging.error("ParserError:", str(e))
            sheets_name = list(dfs.keys())
  "sheets_name {sheets_name}")
                f"Read the raw data from  directory in bolb successfulu. Container: {container_name}, File: {file_name}"
            return dfs, sheets_name, content_byte
        except Exception as e:

    While debugging, you found the issue was specifically with the line dfs = pd.read_excel(downloader.readall(), sheet_name=None, engine="openpyxl")


    You have changed the following line of code to use BytesIO to wrap the binary data to resolve the issue.

    dfs = pd.read_excel(BytesIO(downloader.readall()), sheet_name=None, engine="openpyxl").

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful