I changed my Azure function from using a blobTrigger input to a blob input. This change causes my function to fail. Using the previous binding (blobTrigger), the code works.
Input Binding:
{
"name": "inblob",
"type": "blob",
"direction": "in",
"path": "pre-processed-session-data/{queueTrigger}",
"connection": "kinetyxdev01_STORAGE"
},
Previous Trigger Input Binding (Code works with this binding):
{
"name": "inblob",
"type": "blobTrigger",
"direction": "in",
"path": "pre-processed-session-data/{queueTrigger}",
"connection": "kinetyxdev01_STORAGE"
},
Main Method:
def main(myitem: func.QueueMessage, inblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {inblob.name}\n"
f"Type: {type(inblob)}\n"
f"Blob Size: {inblob.length} bytes")
# read in zip file
logging.info(f"read in zip file")
blob_bytes = inblob.read()
blob_to_read = BytesIO(blob_bytes)
zf = zipfile.ZipFile(blob_to_read)
error message:
Executed 'Functions.ProcessSession' (Failed, Id=91ebae70-5ad1-4d26-81ff-dc1aa19e11d3, Duration=372ms)
System.Private.CoreLib: Exception while executing function: Functions.ProcessSession. System.Private.CoreLib: Result: Failure
Exception: BadZipFile: Bad magic number for central directory
Stack: File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.2881/workers/python/3.8/OSX/X64/azure_functions_worker/dispatcher.py", line 343, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "/Users/omar/opt/anaconda3/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.2881/workers/python/3.8/OSX/X64/azure_functions_worker/dispatcher.py", line 480, in __run_sync_func
return func(**params)
File "/Users/omar/Documents/Kinetyx/OneDrive - Kinetyx Sciences Inc/programs/library-python-data-processing/ProcessSession/__init__.py", line 22, in main
zf = zipfile.ZipFile(blob_to_read)
File "/Users/omar/opt/anaconda3/lib/python3.8/zipfile.py", line 1268, in __init__
self._RealGetContents()
File "/Users/omar/opt/anaconda3/lib/python3.8/zipfile.py", line 1363, in _RealGetContents
raise BadZipFile("Bad magic number for central directory")