1

I am using a blob trigger to read the blob contents, process as a pandas DF and append the blob to the Azure SQL server I am using.

The blob trigger didn't work as expected so I defined all code in the main function as such:

def main(myblob: func.InputStream):
    logging.info(f"Python blob trigger function processed blob \n"
                 f"Name: {myblob.name}\n"
                 f"Blob Size: {myblob.length} bytes")
    file = re.sub(r'^(.*?)\/','',myblob.name)
    if file not in processedfiles:
        stream = BytesIO((myblob.read()))
        stream.seek(0)

However I get the following error:

Exception: FunctionLoadError: cannot load the BlobFileTrigger function: 
binding myblob has invalid non-type annotation <sqlalchemy.sql.functions._FunctionGenerator object at 0x7faa340f6a00>

Can someone help me find the cause of this issue?

The function.json is configured as follows:

{
  "scriptFile": "__init__.py",
  "disabled": false,
  "bindings": [
      {
          "name": "myblob",
          "type": "blobTrigger",
          "direction": "in",
          "path": "input/{name}",
          "connection":"StorageConnection"
      }
  ]
}
0

1 Answer 1

1
  • The configured function.json file is fine.

  • If you are getting an empty byte string, so use the seek(0) method first then Read() from stream.

  • Make sure that if condition is proper on the processedfiles, because if it's not found any files in processedfiles then only your case will execute.

    i.e.:- stream = BytesIO((myblob.read()))

Reference: read() and getvalue() methods of Python io.BytesIO

Azure Functions with Blobtrigger in Python

Sign up to request clarification or add additional context in comments.

3 Comments

It seems importing azure.functions as func collides with func from sqlalchemy, i'll rename and try again. learn.microsoft.com/en-us/answers/questions/568041/…
@Stijn, try with that name like az_func like that and check.
yes, thanks again! After renaming to az_func the script worked as intended!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.