![](/img/trans.png)
[英]IExtensionConfigProvider not initializing or binding with Microsoft.Azure.WebJobs v3
[英]Can Azure Function v1.x be updated to use Microsoft.Azure.WebJobs 3.x?
我正在努力將我們的 Azure Blob Storage (WindowsAzure.Storage) 包從折舊的 9.3.3 版本更新為 Microsoft.Azure.Storage.Blob 替代品。 這需要更新 Microsoft.Azure.WebJobs:v2.2.0 到 v3.0.x。 在完成 package 更新和 azure 功能的以下簽名修訂后; 由於 TraceWriter 導致以下錯誤(修訂版 1),它將不再運行:
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'traceLog' to type TraceWriter. Make sure the parameter Type is supported by the binding. 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.).
然后我嘗試將其轉換為 ILogger(修訂版 2),並得到了類似的錯誤:
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'traceLog' to type ILogger. Make sure the parameter Type is supported by the binding. 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.).
問題
可以為 Microsoft.Azure.WebJobs 從 v2.2.0 更新到 v3.0.x 的 Azure Functions v1.x 嗎? 還是 Azure Functions v1.x 依賴於 Microsoft.Azure.WebJobs v2.2.x? 我缺少什么配置來連接日志?
環境
Azure Functions = 1.38
Target Framework = .NET Framework 4.8
-原來的-
[FunctionName("PlaceOrder")]
public static void OrderImport([BlobTrigger("pending/{filename}", Connection = "storage")]Stream inputBlob, string filename, TraceWriter traceLog)
-修訂版 1-
[FunctionName("PlaceOrder")]
public static void OrderImport([Blob("pending/{filename}", Connection = "storage")]Stream inputBlob, string filename, TraceWriter traceLog)
-修訂版 2(使用 ILogger)-
[FunctionName("PlaceOrder")]
public static void OrderImport([Blob("pending/{filename}", Connection = "storage")]Stream inputBlob, string filename, ILogger traceLog)
您需要做的是將您的 Function 版本從 1.x 遷移到更高版本,並修改您的代碼。
正如我們從文檔中看到的, Function 1.x
支持.NET Framework 4.7
,而.NET Framework 4.8
不受支持。
和,
雖然可以通過手動更新應用程序配置來進行“就地”升級,但從 1.x 升級到更高版本包括一些重大更改。 例如C#中,調試object由TraceWriter改為ILogger。
這是一個關於ILogger
的簡單示例,有關更多信息,您應該 go 到文檔:
public static class SimpleExample
{
[FunctionName("QueueTrigger")]
public static void Run(
[QueueTrigger("myqueue-items")] string myQueueItem,
ILogger log)
{
log.LogInformation($"C# function processed: {myQueueItem}");
}
}
提示:檢查.csproj
文件中的TargetFramework
版本和AzureFunctionsVersion
版本以及Microsoft.Net.Sdk.Functions
NuGet版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.