How to push path from blob output binding to a queue for later processing in Azure Function

Richard Laxton 0 Reputation points
2025-02-27T00:35:21.2166667+00:00

Hi, I have a set of output bindings on an Azure Function (written in PowerShell, because why not) something like this:

   {
      "type": "blob",
      "direction": "out",
      "name": "outputBlobs",
      "path": "output-2025/blob-{DateTime}.json",
      "connection": "scrapeFunction_STORAGE"
    },
    {
      "type": "queue",
      "direction": "out",
      "name": "workQueue",
      "queueName": "work-queue",
      "connection": "scrapeFunction_STORAGE"
    }

The Azure Function calls an API to get a JSON value and then pushes it into the blob binding. There is a separate process which currently enumerates the full set of blobs in the store, potentially hundreds of thousands, and then processes any new blobs using a database table to filter out any previously processed blobs. Blobs are left where they are for redundancy and recovery, although they are periodically archived to stop the performance from becoming too stupid.

Anyway, I wanted to improve efficiency by pushing the name of the freshly written blob into a queue as defined above. Without discarding the whole output binding thing and coding this up myself, how can I achieve this? Is there any way to get the path details from the blob push? I realise that I could just format that string myself, but this could easily tick over to the next second or something and push the wrong path name into the queue.

As far as I can tell, Push-OutputBinding returns nothing, and Get-OutputBinding just seems to return a hashtable of the name of the binding and what has been pushed to it.

Obviously I am doing something stupid, so please set me straight!

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

1 answer

Sort by: Most helpful
  1. Imoh S. Etuk 185 Reputation points MVP
    2025-02-27T01:23:33.99+00:00

    Hi @Richard Laxton

    Apologies for the error you're facing!

    You can try to manually define the blob path and push it to the queue binding yourself. Since PowerShell doesn’t allow direct retrieval of the actual blob path from the output binding. You can update the MyTimerFunction/run.ps1 with the code below:

    param($Timer)

    # Define timestamp format

    $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"

    # Construct blob name using the same timestamp

    $blobPath = "output-2025/blob-$timestamp.json"

    # Generate JSON content (simulate API response)

    $jsonContent = @{

    "id" = "12345"

    "name" = "Example Data"

    } | ConvertTo-Json -Depth 3

    # Push data to Blob Storage

    Push-OutputBinding -Name outputBlobs -Value $jsonContent

    # Push blob path to Queue Storage

    Push-OutputBinding -Name workQueue -Value $blobPath

    Write-Host "Blob written: $blobPath and pushed to queue"

    Then edit the function.json file and configure Blob and Queue output bindings as follows:

    {

    "bindings": [

    {

    "name": "Timer",

    "type": "timerTrigger",

    "direction": "in",

    "schedule": "0 */5 * * * *"

    },

    {

    "name": "outputBlobs",

    "type": "blob",

    "direction": "out",

    "path": "output-2025/blob-{DateTime}.json",

    "connection": "AzureWebJobsStorage"

    },

    {

    "name": "workQueue",

    "type": "queue",

    "direction": "out",

    "queueName": "work-queue",

    "connection": "AzureWebJobsStorage"

    }

    ]

    }

    You can refer to this link https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob?tabs=isolated-process%2Cextensionv5%2Cextensionv3&pivots=programming-language-powershell

    Also, check if this is useful in your case - https://stackoverflow.com/questions/59581748/azure-function-blob-output-binding-path-parameter-javascript

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-output?tabs=python-v2%2Cisolated-process%2Cnodejs-v4%2Cextensionv5&pivots=programming-language-powershell


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.