简体   繁体   中英

The listener for function 'FunctionName' was unable to start in .net core azure

The app is running perfectly in my local using the emulator. But when i deploy to azure to test it, i get this error on the log. I only have one function which is a time trigger.

[10/12/2021 02:32:22 > 79e06d: INFO] The listener for function 'DoWork' was unable to start. [10/12/2021 02:32:22 > 79e06d: INFO] Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'DoWork' was unable to start. [10/12/2021 02:32:22 > 79e06d: INFO] ---> System.Threading.Tasks.TaskCanceledException: A task was canceled. [10/12/2021 02:32:22 > 79e06d: INFO] at Microsoft.Azure.Storage.Core.Executor.Executor.ExecuteAsync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)

I have these on my appsettings

"AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet",

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

{
    "AzureWebJobsStorage": "UseDevelopmentStorage=true", 
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
}

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

When running the function locally, all triggers except http trigger 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 http trigger, because it doesn't use a virtual Storage Emulator.

Try disabling the firewall and see if that resolves the issue, Try the below statement in cmd to check the status

"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" 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

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. Try to copy the same code to a different location.

Install and run Azure Storage Emulator version 5.2 or later. Update the local.appsettings.json file with real Azure Storage Connection Strings.

 {
    "AzureWebJobsStorage": "copy the string in the config function on azure",           
 }

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