【问题标题】:set blob name of azure function with powershell使用powershell设置天蓝色函数的blob名称
【发布时间】:2021-01-12 21:42:34
【问题描述】:

我正在尝试使用 powershell 在 Azure 函数中设置(更改)blob 的文件名。

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"
    }
  ]
}

这只是将 blob 的名称“复制”到另一个容器。

只要我想将目的地 blobname 更改为在我的函数中计算的东西,我就失败了。

我试着设置

{
  "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"
    }
  ]
}

并在我的 run.ps1 中组装 $newname

执行Push-OutputBinding -Name $OutputBlob -Value $Blob 的问题是它希望拥有没有任何属性的 Byte[]-Array。

因此,绑定配置只是采用输入给出的参数。 传递除 Byte[]-Array 以外的其他东西是不可能的...... 这就是为什么我总是得到

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'.

我只想取inputBlob,改个名字,改成outputBlob

【问题讨论】:

  • 你能指定你在哪里使用“newfilename”
  • 我试图在我的函数代码中将 newname 设置为 var 但似乎我无法在我的函数中计算一个完整的新文件名。我通常会尝试在名称中添加时间戳以进行存档。

标签: powershell azure-functions azure-blob-storage


【解决方案1】:

newname 是什么?

当你的函数被触发,并且在触发器中,你绑定到{name},那么你的其他绑定就会知道{name},但是{newname}没有意义。

也许你想要的是container-dest/{name}_output

More info.

【讨论】:

  • 我试图在我的函数代码中将 newname 设置为 var 但似乎我无法在我的函数中计算一个完整的新文件名。我通常试图在名称中添加时间戳以用于存档目的
猜你喜欢
  • 2018-09-01
  • 1970-01-01
  • 2021-03-01
  • 2019-08-11
  • 1970-01-01
  • 1970-01-01
  • 2018-03-24
  • 2022-01-08
  • 2022-08-02
相关资源
最近更新 更多