我正在尝试设置在 blob 存储容器中创建文件时触发的 Powershell Azure 函数。该函数需要处理 blob 文件并将其保存到不同的 blob 存储容器中。
目前该函数什么都不做,因为我正在尝试处理下面的问题。
我无法从 powershell 函数内部访问 blob。我能够使用属性在 c# 中实现这一点,但似乎 powershell 不支持属性。
我尝试在我的函数的集成选项卡下添加一个 Azure Blob 存储输入,路径为“容器名称/{名称}”。但这只会导致错误:“命名参数'name'没有值。”
如何使用事件网格触发器从 powershell 函数访问 blob?
谢谢!
功能:
param($eventGridEvent, $TriggerMetadata, $inputBlob)
$fileName = $TriggerMetadata.Name;
Write-Host "file name: $($fileName)";
Push-OutputBinding -Name outputBlob -Value $fileName
function.json
{
"bindings": [
{
"type": "eventGridTrigger",
"name": "eventGridEvent",
"direction": "in"
},
{
"name": "outputBlob",
"path": "https://storage01.blob.core.windows.net/container-name",
"connection": "Storage01ConnectionString",
"direction": "out",
"type": "blob"
},
{
"name": "inputBlob",
"path": "container-name/{name}",
"connection": "Storage01ConnectionString",
"direction": "in",
"type": "blob"
}
]
}
答案 0 :(得分:1)
对于 setup a Powershell Azure function that is triggered when a file is created in a blob storage container. The function needs to process the blob file and save it to a different blob storage container.
的要求,我认为您可以通过 blob 存储触发器并添加输出绑定(使用另一个 blob 存储容器)来完成。不需要事件网格触发器。
当在 samples-workitems
容器中创建了一个新文件时,它工作正常,然后将文件处理到输出容器 outcontainer
。
答案 1 :(得分:1)
同一函数上不能有多个触发器(输入绑定),因此您需要选择一个:
重要的是每个函数只能有一个输入绑定。