Vivek Nuna
Vivek Nuna

Reputation: 1

The listener for function was unable to start. Why?

I'm getting the following error when I run the azure function from visual studio.

A ScriptHost error has occurred [1/19/2018 6:40:52 AM] The listener for function 'MyFunctionName' was unable to start. Microsoft.WindowsAzure.Storage: Server encountered an internal error. Please try again after some time.

When I run from the command prompt by running func host start command. I get the following warning. and then it gets stuck on

Host lock lease acquired by instance ID

.

No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

Azure function version: [email protected] I'm using Storage Accounts Blob containers and queues.

I'm connecting to Development Storage account, I have checked it that storage emulator is started.

{
  "IsEncrypted": false,
  "Values": {
    "ConnectionStrings:Default": "Server=.\\SQLEXPRESS; Database=TestDb; Trusted_Connection=True;",
    "ConnectionStrings:BlobStorageAccount": "UseDevelopmentStorage=true",

    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
  }
}

FYI.

It was working fine before, But I have got this message in Visual Studio.

your license has gone stale and must be updated. Check for an updated license to continue using this product

So I just deleted the %localappdata% and %temp%, then I tried to run Azure function and after this, I have started getting

The listener for function was unable to start error

So is it related to my visual studio subscription or I mistakenly deleted any required file? Or is this related to something else?

Upvotes: 32

Views: 85916

Answers (16)

Yasin Amini
Yasin Amini

Reputation: 255

You just need to add your azure storage account name and key to the local.settings.json file

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=<accountName>;AccountKey=<accountKey>;EndpointSuffix=core.windows.net",
    "FUNCTIONS_WORKER_RUNTIME": "python"
  }
}

Upvotes: 1

Mutation Person
Mutation Person

Reputation: 30520

I was getting something similar to this with an eraly version of Visual Studio 17.0.x, and Microsoft Azure Queue Explorer (and emulator), not Azurite.

When I upgraded to a later patch (17.6.x) then it started working. Strange that this should be the case.

Upvotes: 0

Muni Chittem
Muni Chittem

Reputation: 1146

solved by following this blog.

https://markgossa.com/2018/12/azure-function-listener-for-function.html

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

Upvotes: 2

tmndungu
tmndungu

Reputation: 347

In my case I deleted everything inside %localappdata% and %temp% folders and started again.

Upvotes: 0

Prem
Prem

Reputation: 432

I am using VS-2022. This issue was resolved using following steps.

  1. Run Azurite, in local machine, using below command

    azurite --silent --location c:\azurite --debug c:\azurite\debug.log

  2. In local.settings.json, use below code:

    "Values": {

    "AzureWebJobsStorage": "UseDevelopmentStorage=true"}

  3. (optional), start the emulator and check that there is no error

That's it!

Upvotes: 4

ingo_ww
ingo_ww

Reputation: 321

I had the problem too and spend many time. The fix is not from me but I hope the onwer can accept it as solution it has spend me much time in past and it can help others.

The only working fix for me was written in the comment above:

The timer in azure-webjobs-hosts was corrupt. It was fixed after deleting the entry. – Marcel Gelijk Mar 5, 2021 at 9:59

On my cases it ssems to happened if you use a timer trigger and change many on them , make duplicates or switch the time trigger to http trigger and back. If you do som stuff for testing it could harm conflicting entries in azure-webjobs-hosts.

So I delete all entries in locks and timers folder. On starting your timer azure functions all Entries will renewed and it worked

Many thanks to Marcel Gelijk.

[Delete all Entries in that 2 folders1

Upvotes: 3

Tahir Alvi
Tahir Alvi

Reputation: 994

if you are running via storage emulator locally then run func settings add AzureWebJobsStorage UseDevelopmentStorage=true in local.settings.json

and if with a normal Azure Storage connection string using func, must set the AzureWebJobsStorage in local.settings.json.
The final JSON would look like this:

{
  // some variables
  "Values": {
    // some variables
    "AzureWebJobsStorage": "UseDevelopmentStorage=true"
  },
}

for more view

Upvotes: 22

robs
robs

Reputation: 950

For anyone else coming across this error when locally running durable functions I found the easiest way to deal with it was by using the VSCode extension "Durable Functions Monitor". I find this an excellent resource for durable functions; using the extension I delete the hub in Azurite storage, which is fast. All the data from any previous executions is removed along with this error.

Upvotes: 0

FritsJ
FritsJ

Reputation: 71

For anyone who bump in this kind of issue, please check this link.

After cleaning the azure storage local container, it solved the issue for me.

Upvotes: 0

delta2_
delta2_

Reputation: 89

I solved the issue doing the following steps: Open up a new terminal and type "azurite". The program will open and keep the window opened. Open visual studio and try to run the function again. Voi la.

Upvotes: 6

chiru
chiru

Reputation: 1007

I solved this problem by setting UseDevelopmentStorage=false in local.settings.json file.

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

Upvotes: -3

Saurabh Rana
Saurabh Rana

Reputation: 167

I was also experiencing the same issue. Exiting the Visual Studio and opening it again resolved the issue in my case.

Upvotes: 0

DarthWader
DarthWader

Reputation: 1046

For me this error was showing up because I didn't have Storage Emulator installed and running. You can install Storage emulator as VS Code plugin from following link. After installing go to VS Code command palette and run Azurite: Start Blob Service. Then run your function locally. It will work fine.

https://marketplace.visualstudio.com/items?itemName=Azurite.azurite

Upvotes: 6

RichS
RichS

Reputation: 3147

For anyone that is encountering this issue the following may help...

Azure Durable Functions rely on TableStorage, and the latest version of Azurite (v3) currently doesn't support TableStorage. As such, pull the Azurite repo and switch to the legacy-master (v2) branch and then run npm run start.

Upvotes: 13

jlo-gmail
jlo-gmail

Reputation: 5048

I just witnessed this. This link https://github.com/Azure/azure-functions-core-tools/issues/357 indicates Local Storage Emulator may not be running. I stopped debugging. Went to the Cloud Explorer and opened the local nodes to see blob content. This must have started the Local storage emulator. When I hit run again, Azure Functions Tools started up.

Upvotes: 7

Sibeesh Venu
Sibeesh Venu

Reputation: 21779

I was getting this issue when I was using ServiceBusTrigger in my Azure functions.

enter image description here

In my visual studio solution I had two Azure Functions and I was using the same Subscription Name for my two Functions, where one function is to send the data to the Azure Service Bus and the other is for receiving the data.

To Send

private const string _topicName = "factfinder_topic";
private const string _subscriptionName = "subs1";
private static ITopicClient _topicClient;
private static ILogger _logger;
[FunctionName("SendDataToSubscription")]
public static void Run([ServiceBusTrigger(_topicName, _subscriptionName, Connection = "ServiceBusConnectionString")] string mySbMsg, ILogger log) {
    _logger = log;
    PrepareSend().GetAwaiter().GetResult();
    _logger.LogInformation($ "C# ServiceBus topic trigger function processed message: {mySbMsg}");
}

To Receive

private const string _topicName = "factfinder_topic";
private const string _subscriptionName = "subs1";
[FunctionName("FetchDataFromSubscription")]
public static void Run([ServiceBusTrigger(_topicName, _subscriptionName, Connection = "ServiceBusConnectionString")] string mySbMsg, ILogger log) {
    log.LogInformation($ "C# ServiceBus topic trigger function processed message: {mySbMsg}");
}

As you could see that the value of the _subscriptionName is subs1 in both case, and this is wrong, so after changing this to my other subscription name (subs2) in the FetchDataFromSubscription function, the issue was resolved.

Upvotes: 2

Related Questions