After deployment Azure Function blob_trigger with Python V2 does not work

Maryna Paluyanava 211 Reputation points


Could anybody help me?

I have a blob storage where new zipped folders with files are loaded into the “input” folder.

I need to create Azure function (blob trigger) that takes the input zipped folder, unzips it without loading to the local folder , and then loads it into "output" folder.
I implemented in the following way using tempfile library... When I debug he function in VS Code using Connection String to the Blob Storage Account all zipped files are unzipped and loaded into output folder. However, when I deploy the function it is not working. What could be the problem?

Thank you!!!

import logging
import azure.functions as func
from import BlobServiceClient
import zipfile
import io
import tempfile
from pathlib import Path

app = func.FunctionApp()

def main(inputzipblob: func.InputStream):"Python blob trigger function processed blob \n"
                f"Name: {}\n")

	connection_string = "XXXXX"

    blob_service_client = BlobServiceClient.from_connection_string(connection_string)
    container_client = blob_service_client.get_container_client("files")

	pdf_files = []
    txt_files = []

    read_zip =
	zip_bytes = io.BytesIO(read_zip)
    is_zip = zipfile.is_zipfile(zip_bytes)

	if is_zip:
	        with zipfile.ZipFile(zip_bytes, 'r') as zip_folder:
	            with tempfile.TemporaryDirectory() as temp_path:
	                for content_filename in zip_folder.namelist():
	                    if '.pdf' in content_filename.lower():
							p = Path(temp_path + '/' + content_filename)
	                    elif '.txt' in content_filename.lower():
	                        p = Path(temp_path + '/' + content_filename)
	                files_to_process = pdf_files + txt_files
	                for file in files_to_process:
	                    blob_name = file[1]
	                    blob_output_path = 'output/'+ blob_name
	                    blob_client_upload = container_client.get_blob_client(blob_output_path)
	                        with open(file[0], "rb") as fl:
	                            blob_client_upload.upload_blob(fl, blob_type="BlockBlob", overwrite=True)
	                    except Exception as e:

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