Azure function version 2.0 - app blobTrigger not working

杀马特。学长 韩版系。学妹 提交于 2019-12-07 05:32:02

问题


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.


回答1:


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

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

  2. Then choose "Azure Blob Storage trigger":

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

  4. From the list, make sure to choose the exact storage account for which you want to be notified.

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

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

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

  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.

Moreover, this is it, no additional references (#r) or usings 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.



来源:https://stackoverflow.com/questions/52148588/azure-function-version-2-0-app-blobtrigger-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!