0
votes

I am trying to set (change) the filename of a blob within a Azure function with powershell.

It is working great by function.json

{
  "bindings": [
    {
      "name": "InputBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "container-src/{name}.{ext}",
      "connection": "stacqadbdev_STORAGE"
    },
    {
      "name": "OutputBlob",
      "type": "blob",
      "direction": "out",
      "path": "container-dest/{name}",
      "connection": "stacqadbdev_STORAGE"
    }
  ]
}

which is just 'copying' the blob's name to another container.

As soon as I want to change to destinations blobname to something which is calculated within my function I am failing.

I tried to set

{
  "bindings": [
    {
      "name": "InputBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "container-src/{name}",
      "connection": "stacqadbdev_STORAGE"
    },
    {
      "name": "OutputBlob",
      "type": "blob",
      "direction": "out",
      "path": "container-dest/{newname}",
      "connection": "stacqadbdev_STORAGE"
    }
  ]
}

and assembling $newname in my run.ps1

Doing Push-OutputBinding -Name $OutputBlob -Value $Blob has the issue that it wants to have the Byte[]-Array which has no properties for its name or so.

So, the bindings configuration is just taking the parameters given by input. Passing something else than the Byte[]-Array is not possible... That's why I always get

Executed 'Functions.CreateVaultEntry' (Failed, Id=775e61ce-b001-4278-a8d8-1c90ea63c062, Duration=91ms)
System.Private.CoreLib: Exception while executing function: Functions.CreateVaultEntry. 
Microsoft.Azure.WebJobs.Host: No value for named parameter 'newfilename'.

I just want to take the inputBlob, change it's name and write it as outputBlob with another name.

1
Can you please specify where you use "newfilename"Markus Meyer
I was trying to set newname as var within my function code but it seems that I can not compute a complete new filename within my function. I was in general trying to add a timestampe to the name for archiving purposes.Matthias Fleschütz

1 Answers

0
votes

What is newname ?

When your function is triggered, and in the trigger, you are binding to {name}, then your other bindings will have knowledge of {name}, but {newname} does not make sense.

Perhaps what you want is container-dest/{name}_output

More info.