1

I'm trying to setup an Azure Function, Linux based in consumption mode, Queue triggered. It works perfectly locally in debug (said every programmer ever), but when deploying nothing happens. I can't find any logs.

I started over, uploaded an empty function - it worked, but as soon as I add my own libraries, it stopped working.

I then tried to remove my libraries and re-upload the 'hello world' function but it still doesn't work.

This is the host.json:

   {
  "logging": {
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Information",
      "Host.Results": "Information",
      "Function": "Information",
      "Host.Aggregator": "Information"
    },
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    },
    "console": {
      "isEnabled": "true"
    }
  },
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=****;AccountKey=*****;BlobEndpoint=https://***.blob.core.windows.net/;TableEndpoint=https://*****.table.core.windows.net/;QueueEndpoint=https://****.queue.core.windows.net/;FileEndpoint=https://****.file.core.windows.net/",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  },
  "version": "2.0"
}

The function code (without my libraries), works on first upload only.

[FunctionName("EmailQueueWorker")]
        //public static async Task Run(
        public static async Task Run(
            [QueueTrigger(queueName: "email", Connection = "AzureWebJobsStorage")] string queueItem,
            ILogger log
        )
        {
            log.LogWarning("Start run()");
        }

What am I doing wrong (or where can I find logs? the Application Insights is empty)? Thanks

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
NOP-MOV
  • 792
  • 2
  • 8
  • 28

1 Answers1

2

I ran into the same problem a week or two ago; I'd bet good money the problem is your connection to the queue. For comparison, this is my full and complete host.json for my (working) queue trigger function:

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true
            }
        },
        "fileLoggingMode": "always",
        "logLevel": {
            "default": "Information",
            "Host.Results": "Error",
            "Function": "Trace",
            "Host.Aggregator": "Trace"
        }
    }
}

Connection String

Our logLevel section is a bit different, and you'll note there aren't any connection strings there. I'm still farely new to Azure but from what I've learned, that isn't where they go.

In Visual Studio 2019, right click on the Project, then Publish. Under Actions, click Manage Azure App Service settings. There, you can add any needed connection string settings. If you need to specify a storage account, the setting name should be the name of the storage account plus "_STORAGE". For example, if your storage account was named MyVault then the name of the setting would be MyVault_STORAGE.

In VS Code, it's a bit different to get to. You have to look under Azure, Functions, and then be sure you select your Azure subscription (not the local copy!) and drill down into the function, Application Settings, where you can add/edit.

In the Azure portal, you can manage app settings this way.

Logs

In Azure portal, start by going to Function App. Click on your primary function name. Now, under the new menu for that function, under Functions sub-menu, click on Functions. Now you'll see a list of all the different functions that comprise your queue trigger function. Among them should be EmailQueueWorker - click on it. Now, you should see the execution count, and you can click on Monitor in the left hand menu, then Logs in the middle area. You can Start/Stop/Clear as needed.

For whatever reason, I find that I see the actual log data a lot faster when I use either Visual Studio 2019 or VS Code to stream it rather than the web console. There seems to be a bit of a delay at times with the web console.

technonaut
  • 484
  • 3
  • 12