10
votes

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?

7
I think we're going to need some more information to be able to help you. I assume since you're having the problem you're talking about an .NET base Azure Function running on the 1.x runtime? Also, what kind of trigger are you using (storage queue, service bus queue/topic, something else)? If there's any way you can put your project somewhere out in the open (e.g. GitHub) that would be awesome, but if you can't it might just take a little more back and forth.Drew Marsh
Thanks Drew, I updated my questionvivek nuna
If you have your function app running in Azure (or somewhere else) using the same host ID, then that instance may take the lease, and your locally running copy would not be running functions.Make sure all of the connection you have fill down.Joey Cai
@JoeyCai but it’s not working with VS?vivek nuna
@JoeyCai any updates on this?vivek nuna

7 Answers

6
votes

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.

3
votes

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.

3
votes

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

2
votes

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

0
votes

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.

0
votes

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

0
votes

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

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