Python Azure Function run on startup despite run_on_startup=False

Maria Dąbrowiecka 80 Reputation points
2025-03-24T10:22:53.3333333+00:00

Hi,

I run my Azure Function inside the docker container deployed on my local computer. I've noticed every time the container is up and running and Azure Function is started my function is triggered immediately. I've added run_on_startup=False to the blob trigger decorator but it doesn't work - my function still gets triggered.

Here's my function:

import logging

import azure.functions as func
import azurefunctions.extensions.bindings.blob as blob

app = func.FunctionApp()

@app.blob_trigger(arg_name="client",
                  path="blobclient/{name}.csv",
                  connection="BlobStorageConnectionString",
                  run_on_startup=False
                  )
def function(client: blob.BlobClient):
    logging.info(
        f"Python blob trigger function processed blob \n"
        f"Properties: {client.get_blob_properties()}\n"
    )

Is there anything I'm missing?
Another question - what is the default value of this setting?

Thanks a lot, Maria

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Marten Theunissen 676 Reputation points
    2025-03-24T10:30:43.02+00:00

    Consider using an Event Grid trigger instead of a blob trigger. Event Grid can provide more control over when the function is triggered based on specific events:

    @app.event_grid_trigger(arg_name="event",

                        connection="EventGridConnectionString")
    

    def function(event: func.EventGridEvent):

    logging.info(
    
        f"Python Event Grid trigger function processed event \n"
    
        f"Event: {event.get_json()}\n"
    
    )
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.