0

Very new to Azure and Function Apps.

I'm trying to set up a simple Function app using Powershell which needs to read the content from a blob (simple .txt file), do some simple processing on it and write a copy of that file into different blob.

So far I have set up the integration on the app, which I can see provides a binding I can use. Looks like this:

 {
  "name": "inputBlob",
  "direction": "in",
  "type": "blob",
  "path": "input/logs.txt",
  "connection": "AzureWebJobsStorage"
}

I'm referencing that binding in the powershell params at the start of the script:

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata, $inputBlob)

As I understand things this should allow me to connect to that blob and interact with it. What I don't understand is how should that be done? I have tried to use the cmdlet that seems to make the most sense for the situation: Get-AzStorageBlobContent

for example:

$blobContent = Get-AzStorageBlobContent -name $inputBlob

But when I try to return that content in my http reponse (so I can check that it was read), the response body is empty.

I presume that I will need to add further bindings for outputing to blobs too?

For example, the Set-AzStorageBlobContent cmdlet seems to only support 'files' but in my case within the function app, I don't have a file, just a string or an array, so how do I push that content into the target blob?

Would appreciate any pointers on how to achieve this,

1 Answer 1

1

The $inputBlob variable should contain the blob data as an array of bytes, so you can do:

foreach ($value in $inputBlob) { ... }

or anything else you would do with an array of bytes.

If you need to output to a blob, you need to add an output binding:

    {
      "name": "myOutputBlob",
      "type": "blob",
      "path": "output/data.txt",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }

and push the data to this binding from your function code:

Push-OutputBinding -Name myOutputBlob -Value 'my value'
Sign up to request clarification or add additional context in comments.

1 Comment

Fantastic. Works brilliantly. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.