Azure 函数抛出异常以修改仪表板上的 azure 自定义字段

Azure function throw exception to modify azure custom field on dashborad

我创建了一个函数来自动计算 azure board 任务的自定义日志小时数。我按照下面link来实现它,

https://tfsaggregator.github.io/docs/v3/

使用以上 link 一些其他开发人员成功实现,但 1 年后 PAT 过期并且功能完全停止。现在我再次按照相同的步骤执行它,并使用新 PAT 添加了新规则。但是,当我更改记录时间时,出现了以下异常,而我完全没有意识到这一点。

2022-05-24 13:30:55.026
Executing 'Functions.AutoCal' (Reason='This function was programmatically called via the host APIs.', Id=4650-4f75-9324-5823890a50b7)
Information
2022-05-24 13:30:55.161
Error
2022-05-24 13:30:55.161
Function compilation error
Error
2022-05-24 13:30:55.225
run.csx(14,23): error CS1705: Assembly 'aggregator-function' with identity 'aggregator-function, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.Extensions.Logging.Abstractions' with identity 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.23.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Error
2022-05-24 13:30:55.297
run.csx(15,27): error CS1705: Assembly 'aggregator-webshared' with identity 'aggregator-webshared, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.Extensions.Logging.Abstractions' with identity 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.23.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Error
2022-05-24 13:30:55.297
run.csx(16,24): warning CS1701: Assuming assembly reference 'Microsoft.AspNetCore.Mvc.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' used by 'aggregator-function' matches identity 'Microsoft.AspNetCore.Mvc.Abstractions, Version=3.1.23.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' of 'Microsoft.AspNetCore.Mvc.Abstractions', you may need to supply runtime policy
Warning
2022-05-24 13:30:55.367
Script compilation failed.
Error
2022-05-24 13:30:55.367
Executed 'Functions.AutoCal' (Failed, Id=4650-4f75-9324-5823890a50b7, Duration=358ms)
Error
2022-05-24 13:30:55.371
Script compilation failed.

我解决了我的问题。我们需要如下,

Dotnet 运行时版本 3.1 或从 Aggregator 文档中推荐。 最新版聚合器exe.

注意:.rule 文件在 javascript 中,因此它不会受到上述任何版本更改的影响。因此,始终使用最新版本的聚合器和推荐的 dotnet 运行时版本。

最佳替代解决方案是 Microsoft Flow, https://www.dombat.co.uk/using-microsoft-flow-to-fill-calculated-fields-in-azure-devops/

https://www.youtube.com/watch?v=SK86TLZQw9A

以上解决方案在不刷新页面的情况下提供计算值。