![](/img/trans.png)
[英]The listener for function '' was unable to start. Azure durable function VS 2022
[英]Listener for function was unable to start. Azure function app timetrigger
當我在本地環境中從 Visual Studio 運行 azure 函數時出現以下錯誤:
函數“Function1”的偵聽器無法啟動。 Microsoft.WindowsAzure.Storage:錯誤請求。
這是我的代碼
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}");
}
}
}
和配置(即local.settings.json)
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
但是當我設置一個 http 觸發功能應用程序時,它工作正常。
更新:
由於您使用本地虛擬化存儲模擬器,因此您的連接字符串是正確的。
如果您的防火牆限制 func 訪問存儲帳戶,則可能會報告此錯誤。 防火牆是監聽器無法訪問虛擬存儲模擬器的原因之一。
在本地運行該函數時,除 httptrigger 之外的所有觸發器都需要使用存儲模擬器。 如果防火牆限制偵聽器對虛擬存儲的訪問,則在執行功能時可能會出現問題。 這就是使用 httptrigger 不會出錯的原因,因為它不使用虛擬存儲模擬器。
嘗試禁用防火牆,看看是否可以解決問題。
當然也有可能是Storage Emulator服務沒有打開。 嘗試打字
"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" status
在cmd中查看狀態。
如果返回 false,請輸入以下命令以啟動存儲模擬器:
"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" init
"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" start
總結:
這種類型的問題通常是由三個原因造成的。
1.連接字符串錯誤阻止連接,
2.防火牆設置
3.部分服務未開啟。
希望能幫助到你。
原答案:
相同的代碼在我這邊工作正常,
解決方案:
嘗試將相同的代碼復制到不同的位置。
也許 這可以幫助你。
我發現問題在於我在另一個驅動器中運行了 Azure 存儲模擬器,然后我有了我的項目。 即模擬器在 C:\\Emulator 上運行,項目在 S:\\MyFunction 上本地運行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.