Azure函数版本2.0-应用程序BlobTrigger无法正常工作 [英] Azure function version 2.0 - app blobTrigger not working

查看:105
本文介绍了Azure函数版本2.0-应用程序BlobTrigger无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行中的功能应用程序,该应用程序具有Blob输入和事件中心输出(在Beta中工作). 随着最新的更改,我的功能不再起作用. 我已经尝试根据发行说明更新host.json文件,但它没有引用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
}

此外,升级时 从1.0.14到1.0.19的Microsoft.NET.Sdk.Functions无法识别blobTrigger属性,并且我的代码无法编译:

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

如前所述,这是由于上一次Azure Function App更新导致的,我还没有看到任何有关如何在此新2.0版本中使用Blob触发器的示例.

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.

推荐答案

要将Azure Function与Blob文件更新连接,请执行以下步骤.

To connect Azure Function with Blob file updates, do the following steps.

  1. 从功能"菜单中单击"+"图标.

  1. Click on the '+' icon from the Functions menu.

然后选择"Azure Blob存储触发器":

Then choose "Azure Blob Storage trigger":

将打开一个弹出式/侧边栏,然后您需要填写与blob相关的信息.
这很容易,但是首先,单击新建"链接,它将弹出另一个视图,您可以在其中查看您的存储帐户列表.

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.

您应该看到存储名称出现在存储帐户连接"输入框下(您还可以在存储名称的末尾看到一些其他标签,例如"..._ STORAGE",没关系) .

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

除了帐户连接,还需要提供容器名称,如果您选中存储帐户的"Blob"部分,则可以找到该容器名称.

Besides the account connection, you also need to provide the container name, which you can find if you check your storage account "Blobs" section.

现在,创建blob触发器之前的最终外观应该是:

Now the final look before creating the blob trigger should be:

请确保不要触摸路径输入下的{name}部分.需要该变量来反映更改的文件/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.

  1. 最后,点击创建"按钮,然后尝试在您的Blob容器中上传任何文件. 您应该看到代表更改的日志.
  1. 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.


就是这样,不需要其他引用(#r)或using即可查看Blob的变化.


Moreover, this is it, no additional references (#r) or usings are necessary to see the blob changes.

请注意,日志"部分下的斑点更改可能会有所延迟. 但是,如果一段时间后仍看不到任何更新,请再次检查您是否提供了正确的存储帐户和容器名称.为此,您可能需要再次创建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.

这篇关于Azure函数版本2.0-应用程序BlobTrigger无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆