Can't get an Azure Powershell Function to run when a blob is created

Richard Duane Wolford Jr 226 Reputation points
2023-08-13T09:07:51.9533333+00:00

I'm having a heck of a time here, and I've followed the MS instructions to no avail. It's really simple what I want to do. When a blob is written to a container named "test", I want a PowerShell function to execute. The PowerShell function needs to only know the name of the blob created (in this case I'm testing with a file name "test1.csv"). When the test/test1.csv blob is created, the PowerShell is going to grab it and do some work with it, then it will end up writing a file to another container in the same storage account (not really the problem right now though). What in the world am I doing wrong? Can someone walk me through this? I've create a consumption-based function with the PowerShell stack, but I can't get anything to work, the Powershell script just doesn't seem to get executed.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,692 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,141 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,861 Reputation points Microsoft Employee
    2023-08-14T02:42:57.9533333+00:00

    Hello @Richard Duane Wolford Jr - Thanks for reaching out!

    If the issue is that your trigger isn't firing at all, I would carefully review the table in the following doc & make sure that a correct configuration is being used against a matching storage account version: Trigger on a blob container. Although when working with blobs, the general rule of thumb is to use event-based triggers if possible.

    If all that needs to be accomplished for now is a copy operation between containers in the same storage account, I think that your code & config can be much simpler as shown in the following example: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-output?tabs=python-v2%2Cin-process&pivots=programming-language-powershell#example

    You might also try using Set-AzStorageBlobContent instead of the Start-AzureStorageBlobCopy cmdlet.

    If the issue still persists despite validating config against a correct storage account and simpler code based on the above, let me know and I'll help troubleshoot as the root cause may likely be within your unique environment.


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.