我有一个工作函数应用程序,它有一个 blob 输入和一个事件中心输出(在测试版中工作)。 随着最新的更改,我的功能不再起作用。 我尝试根据发行说明更新 host.json 文件,但它没有引用 blob 触发器:
{
"version": "2.0",
"extensions": {
"blobTriggers" : {
"name": "blob",
"type": "blobTrigger",
"direction": "in",
"path": "iot3gblobs/{name}",
"connection": "AzureWebJobsStorage"
},
"eventHubs": {
"type": "eventHub",
"name": "outputEventHubMessages",
"path": "ioteventhub",
"connection": "IoTEventHubConnection",
"cardinality": "many",
"direction": "out"
}
},
"Host" :
{
"LocalHttpPort": 7071,
"CORS": "*"
},
"disabled": false
}
另外,升级时 Microsoft.NET.Sdk.Functions 从 1.0.14 到 1.0.19 blobTrigger 属性无法识别,我的代码将无法编译:
[FunctionName("iotserverparser")]
public async static Task Run(
[BlobTrigger("iot3gblobs/{name}", Connection = "AzureWebJobsStorage")]
Stream blob,
[EventHub(
"outputEventHubMessages", Connection =
"IoTEventHubConnection")]
如前所述,这是由于上次 Azure Function App 更新造成的,我还没有看到任何有关如何在这个新的 2.0 版本中使用 Blob 触发器的示例。
最佳答案
要将 Azure Function 与 Blob 文件更新连接,请执行以下步骤。
单击“功能”菜单中的“+”图标。
然后选择“Azure Blob 存储触发器”:
弹出窗口/侧边栏打开后,您需要填写 Blob 相关信息。
这非常简单,但首先,单击"new"链接,它将弹出另一个 View ,您可以在其中查看存储帐户列表。从列表中,确保选择您想要收到通知的确切存储帐户。
之后您将看到存储名称出现在“存储帐户连接”输入框下方(您还可能会看到存储名称末尾附加了一些附加标签,例如“..._STORAGE”,没关系) .
除了帐户连接之外,您还需要提供容器名称,您可以通过查看存储帐户的“Blob”部分找到该名称。
现在创建 blob 触发器之前的最终外观应该是:
<小时/>Here make sure you don't touch the
{name}
part under the Path input. That variable is needed to reflect the changed file/blob name.
此外,就是这样,不需要额外的引用 (#r
) 或 using
来查看 blob 更改。
Note that blob changes might reflect with a bit delay under the Logs section. However, if after some time you still don't see any updates there then check once more that you have provided correct Storage Account and container names. To do that you might need to create the blob trigger again.
关于c# - Azure函数版本2.0-应用程序blobTrigger不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52148588/