问题描述
我有一个正常工作的函数应用程序,它有一个 blob 输入和一个事件中心输出(在测试版中工作).随着最新的变化,我的功能不再起作用.我已尝试根据发行说明更新 host.json 文件,但它没有引用 blob 触发器:
<代码>{版本":2.0",扩展":{blobTriggers":{名称":斑点",类型":blobTrigger",方向":在",路径":iot3gblob/{name}",连接":AzureWebJobsStorage"},事件中心":{类型":事件中心","name": "outputEventHubMessages",路径":ioteventhub","connection": "IoTEventHubConnection",基数":许多",方向":出去"}},主持人" :{LocalHttpPort":7071,CORS":*"},禁用":假}
另外,升级时Microsoft.NET.Sdk.Functions 从 1.0.14 到 1.0.19 无法识别 blobTrigger 属性,我的代码将无法编译:
[FunctionName("iotserverparser")]公共异步静态任务运行([BlobTrigger("iot3gblob/{name}", Connection = "AzureWebJobsStorage")]流 blob,[事件中心(outputEventHubMessages",连接 ="IoTEventHubConnection")]
如前所述,这是因为上次 Azure Function App 更新,我还没有看到任何关于如何在这个新的 2.0 版本中使用 Blob Trigger 的示例.
要将 Azure Function 与 Blob 文件更新连接,请执行以下步骤.
单击功能"菜单中的+"图标.
然后选择Azure Blob Storage trigger":
弹出/侧边栏打开后,您需要填写您的 blob 相关信息.
这很简单,但首先,单击新建"链接,它会弹出另一个视图,您可以在其中看到您的存储帐户列表.确保从列表中选择您希望收到通知的确切存储帐户.
在存储帐户连接"输入框下会看到存储名称(您可能还会看到存储名称末尾附加了一些附加标签,例如..._STORAGE",没关系).
除了帐户连接,您还需要提供容器名称,您可以在您的存储帐户Blob"部分找到该名称.
现在创建 blob 触发器之前的最终外观应该是:
<块引用>
这里确保您不要触摸 Path 输入下的 {name}
部分.需要该变量来反映更改的文件/blob 名称.
- 最后,点击创建"按钮,然后尝试上传 Blob 容器中的任何文件.您应该会看到代表更改的日志.
<小时>
此外,就是这样,不需要额外的引用 (#r
) 或 using
s 来查看 blob 更改.
请注意,在日志"部分下,blob 更改可能会有所延迟.但是,如果一段时间后您仍然看不到任何更新,请再次检查您是否提供了正确的存储帐户和容器名称.为此,您可能需要再次创建 blob 触发器.
I had a working Function App that got a blob input and an event hub output (worked in beta). With latest changes, my function no longer works. I've tried to update the host.json file according to the release note, but it has not reference to blob trigger:
{
"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
}
Also, when upgrading Microsoft.NET.Sdk.Functions from 1.0.14 to 1.0.19 the blobTrigger attribute is not recognized and my code will not compile:
[FunctionName("iotserverparser")]
public async static Task Run(
[BlobTrigger("iot3gblobs/{name}", Connection = "AzureWebJobsStorage")]
Stream blob,
[EventHub(
"outputEventHubMessages", Connection =
"IoTEventHubConnection")]
As mentioned before, this is because of the last Azure Function App update and I have not seen any example of how to work with Blob Trigger in this new 2.0 version.
To connect Azure Function with Blob file updates, do the following steps.
Click on the '+' icon from the Functions menu.
Then choose "Azure Blob Storage trigger":
After a popup/sidebar will open, and you need to fill your blob related information.
That is quite easy, but first, click on the "new" link and it will popup another view where you can see the list of your storage accounts.From the list, make sure to choose the exact storage account for which you want to be notified.
After you shall see the storage name appearing under the "Storage account connection" input box (you may also see some additional label appended at the end of storage name, like "..._STORAGE", that's ok).
Besides the account connection, you also need to provide the container name, which you can find if you check your storage account "Blobs" section.
Now the final look before creating the blob trigger should be:
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.
- Finally, click on the "Create" button and after try to upload any file in your blob container. You should see the logs representing the changes.
Moreover, this is it, no additional references (#r
) or using
s are necessary to see the blob changes.
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.
这篇关于Azure 函数 2.0 版 - 应用 blobTrigger 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!