Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listener for function was unable to start. Azure function app timetrigger

I'm getting the following error when I run the azure function from visual studio in local environment:

The listener for function 'Function1' was unable to start. Microsoft.WindowsAzure.Storage: Bad Request.

Here is my code

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

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

and configuration (i.e, local.settings.json)

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

But when I setup a http trigger function app, it works fine.

like image 759
highbury zhu Avatar asked Nov 25 '19 06:11

highbury zhu


2 Answers

Update:

Since you use a locally virtualized Storage Emulator, then your Connecting String is correct.

If your firewall restricts func from accessing the Storage Account, then this error may be reported. The firewall is one of the reasons that the listener cannot access the virtual Storage Emulator.

When running the function locally, all triggers except httptrigger need to use the Storage Emulator. If the firewall restricts the listener's access to virtual storage, problems can occur when performing functions. That's why you don't get errors with httptrigger, because it doesn't use a virtual Storage Emulator.

Try disabling the firewall and see if that resolves the issue.

Of course, it is also possible that the Storage Emulator service is not open. Try typing

"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" status

in cmd to check the status.

If it returns false, enter the following command to start the Storage Emulator:

"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" init
"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" start

To sum up:

This type of problem is generally for three reasons.

1.Connection string error prevents connection,

2.firewall is set

3.some services are not turned on.

Hope it helps.


Original Answer:

Same code works fine on my side,

Solution:

Try to copying the same code to a different location.

Maybe this can help you.

like image 106
Cindy Pau Avatar answered Sep 16 '22 16:09

Cindy Pau


If this happening in Visual Studio Code, it may be due to local emulator not started.

Install Azurite plugin in VS Code and then start it. enter image description here

https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite?toc=/azure/storage/blobs/toc.json

To start the emulator, open the command palette by pressing F1 in Visual Studio Code and then execute the following command.

Azurite: Clean

enter image description here

like image 36
Paramesh Korrakuti Avatar answered Sep 16 '22 16:09

Paramesh Korrakuti