简体   繁体   中英

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 (eg ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (eg config.UseServiceBus(), config.UseTimers(), etc.).

Azure function version: azure-functions-core-tools@2.0.1-beta.22 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?

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 .

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

for more view

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.

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

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!

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

在此处输入图片说明

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.

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

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

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

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.

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.

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.

I had the problem too and spend many time. The fix is not from me but I hope the onwer can accepot 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.

[ 删除这 2 个文件夹中的所有条目1

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

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

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 (eg ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (eg config.UseServiceBus(), config.UseTimers(), etc.).

Azure function version: azure-functions-core-tools@2.0.1-beta.22 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM