【发布时间】: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