[Python] azure blob trigger is not working when files uploaded in the storage container...

Discussão em 'Python' iniciado por Stack, Fevereiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to implement azure blob trigger in python. So whenever a file gets uploaded, blob trigger should read those files and apply logic over those file's data.

    File is getting uploaded into the container but blob trigger is not working.

    I've gone through official documentation Azure Blob storage trigger for Azure Functions

    function.json

    {
    "name": "upload_file",
    "entryPoint": "upload_file",
    "scriptFile": "function_app.py",
    "language": "python",
    "functionDirectory": "/home/site/wwwroot",
    "bindings": [
    {
    "direction": "IN",
    "type": "blobTrigger",
    "name": "client",
    "path": "<container-name>/{name}",
    "connection": "<storage account connection string>"
    }
    ]
    }


    Blob Trigger Code


    connection_string = os.getenv('BLOB_ENDPOINT')
    container_name = os.getenv('BLOB_CONTAINER')

    @app.function_name(name="upload_file")
    @app.blob_trigger(
    arg_name="client", path=f"{container_name}/{{name}}", connection=connection_string
    )
    def upload_file(client: func.InputStream) -> func.HttpResponse:
    """Handle Excel file upload and manage Cosmos DB containers."""
    logging.info(f"Python blob trigger function processed blob \n"
    f"Name: {client.name}\n"
    f"Blob Size: {client.length} bytes")


    also configured environment variables in azure function.

    local.setting.json

    {
    "IsEncrypted": false,
    "Values": {
    "AzureWebJobsStorage": "<storage account connection string>",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
    }
    }



    Thanks in advance

    Continue reading...

Compartilhe esta Página