Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure function version 2.0 - app blobTrigger not working

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.

like image 558
Dani Toker Avatar asked Sep 03 '18 11:09

Dani Toker


People also ask

How do I check Azure function app version?

In the Azure portal, browse to your function app. Under Settings, choose Configuration. In the Function runtime settings tab, locate the Runtime version. Note the specific runtime version.

How do I enable Azure function app?

Sign in to the Azure portal, then search for and select Function App. Select the function you want to verify. In the left navigation under Functions, select App keys.

How do I manually trigger Azure function?

Navigate to your function app in the Azure portal, select App Keys, and then the _master key. In the Edit key section, copy the key value to your clipboard, and then select OK. After copying the _master key, select Code + Test, and then select Logs.

How do I check logs on Azure function app?

From the Monitoring section of your function app in the Azure portal, select Diagnostic settings, and then select Add diagnostic setting. In the Diagnostics settings page, under Category details and log, choose FunctionAppLogs. The FunctionAppLogs table contains the desired logs.


1 Answers

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

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

    enter image description here

  2. Then choose "Azure Blob Storage trigger":

    enter image description here

  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.

    enter image description here

  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.

    enter image description here

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

    enter image description here

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. enter image description here

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.

like image 104
Arsen Khachaturyan Avatar answered Oct 13 '22 20:10

Arsen Khachaturyan