Pass Parameter to Azure Powershell Function

Jayant Yadav 1 Reputation point
2022-09-10T07:22:33.75+00:00

I'm new to the Azure environment. I want to execute an .exe file by passing blob storage as an input and output parameter

below is my Json Function and PowerShell code I am not sure how to pass the input blob storage file as parameter and get the output on the blob storage.

I tried to run the below code but i am getting error

Function.json
{
"bindings": [
{
"name": "Timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */5 * * * *"
},
{
"name": "inputBlob",
"direction": "in",
"type": "blob",
"path": "inputfilepath/{name}",
"connection": "test23_STORAGE"
},
{
"name": "outputBlob",
"direction": "out",
"type": "blob",
"path": "outputfilepath/{name}",
"connection": " test23_STORAGE"
}
]
}
Run.ps1

**# Input bindings are passed in via param block.
param($Timer,$inputBlob,$outputBlob)

Get the current universal time in the default string format.

$currentUTCtime = (Get-Date).ToUniversalTime()

The 'IsPastDue' property is 'true' when the current function invocation is later than scheduled.

if ($Timer.IsPastDue) {
Write-Host "PowerShell timer is running late!"
}

Write an information log with the current time.

Write-Host "PowerShell timer trigger function ran! TIME: $currentUTCtime"
Set-Location "C:\home\site\wwwroot\TimerTrigger1"
.\Extractor.exe -F $inputBlob -E $outputBlob**

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,907 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,793 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,511 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,221 Reputation points
    2022-09-16T07:49:04.413+00:00

    Hi. Thank you for your question and reaching out. My name is John and I’d be more than happy to help you with your query.

    You can try the following:

    [FunctionName("BlobInput")]
    public static void Run(
    [QueueTrigger("myqueue-items")] string myQueueItem,
    [Blob("samples-workitems/{queueTrigger}", FileAccess.Read)] Stream myBlob,
    ILogger log)
    {
    log.LogInformation($"BlobInput processed blob\n Name:{myQueueItem} \n Size: {myBlob.Length} bytes");
    }

    For more information, please see https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-input?tabs=in-process%2Cextensionv5&pivots=programming-language-csharp

    ----------------------------------------------------------------------------------------------------------------------------

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    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.