azure-functions-python-worker icon indicating copy to clipboard operation
azure-functions-python-worker copied to clipboard

[FeatureRequest] Add binding at runtime

Open flvndh opened this issue 2 years ago • 3 comments

Input and output bindings are great abstractions for those who want to avoid using clients. Unfortunately, there are still cases where you are forced to use a client. Take for example this one:

Whenever a blob appear at /abc/{date}/{filename}.{ext} copy it to /xyz/year={year}/month={month}/day={day}/{filename}.{ext}

It requires the binding to be set at runtime which is currently not possible in Python.

An option could be to set the output path on the Out class like this:

@app.blob_trigger(
    arg_name="input_blob",
    path="abc/{date}/{filename}.{ext}",
    connection="abc",
)
@app.blob_output(
    arg_name="output_blob",
    connection="xyz",
)
def copy_blob(input_blob: func.InputStream, output_blob: func.Out[str]):
    # Logic
    output_blob.set(output, path=f"xyz/year={year}/month={month}/day={day}/{filename}.{ext}")

flvndh avatar Dec 19 '22 08:12 flvndh