Nandan Acharya
Nandan Acharya

Reputation: 970

The listener for function 'Function1' was unable to start

While running a simple Timer Trigger Azure Function locally, I'm getting below error.

I create new Azure Functions project with timer trigger using Visual Studio 2019.

I have Azure development Workload installed. Azure development Workload installed

Code:

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace FunctionApp1
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([TimerTrigger("*/12 * * * * *")]TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
        }
    }
}

Error:

[2021-11-24T15:45:29.878Z] The listener for function 'Function1' was unable to start.
[2021-11-24T15:45:29.880Z] The listener for function 'Function1' was unable to start. Azure.Storage.Blobs: Server encountered an internal error. Please try again after some time.
RequestId:3bb00ada-83ec-4685-987b-5d4b51cb39db
Time:2021-11-24T15:45:29.5583585Z
[2021-11-24T15:45:29.880Z] Status: 500 (Server encountered an internal error. Please try again after some time.)
[2021-11-24T15:45:29.881Z] ErrorCode: InternalError

This answer suggests to disable the firewall. It seems firewall is the issue for me also. When disabling firewall is not an option, is there any way to overcome this?

Upvotes: 4

Views: 11813

Answers (2)

fsbflavio
fsbflavio

Reputation: 874

Recently, I also encountered the error in Visual Studio 2022.

The solution:

  1. Download and install the Microsoft Azure Storage Explorer. On the download page select your operating system from the drop-down menu.

  2. With Visual Studio open, and with the Azure Function project set as Startup Project, Open the Azure Storage Explorer by typing its name in the Windows start menu.

  3. In the left menu, expand Storage Accounts -> (Emulator - Default Ports) (key) -> Blob Containers. Then left-click on azure-webjobs-hosts and select Delete.

  4. Restart Visual Studio. Everything should work now.

References:
Cameron Dwyer blog
Issue on github

Upvotes: 4

anon
anon

Reputation:

After all the discussions, glad that your issue got resolved.

Here is my solution to help the other community members as tested in my local environment:

Below is the code:

local.settings.json

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }
}

Function1.cs

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace KrishTimerTriggerNetCore31
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([TimerTrigger("*/12 * * * *")]TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
        }
    }
}

Output:

enter image description here

When you created the azure functions project in Visual Studio with timer trigger template, by default your local.settings.json file contains this value "AzureWebJobsStorage": "UseDevelopmentStorage=true"

If the UseDevelopmentStorage to none, then the same error will occurs:

enter image description here

Make Sure all required applications are installed and up to date for your requirement like Azure Functions Core Tools Version, Azure Storage emulator (locally), .Net Core Runtime Versions and SDKs and the extensions while installing Visual Studio.

Upvotes: 7

Related Questions