概要
nodeをv22にあげたら azure-functions-core-tools で起動できなくなった。
azure-functionsはnode22に対応したといっている。
chocolateyで導入したazure-functions-core-toolsが4.0.6518
のバージョンを指していることが原因だった。
下記コマンドでshimgenを作り直し、4.0.6594
にアップデートすることで解決した。
c:\ProgramData\chocolatey\tools\shimgen.exe --output=c:\ProgramData\Chocolatey\bin\func.exe --path="C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\func.exe"
環境
- Windows
11 Home 23H2 22631.4391
- chocolatey
2.3.0
- azure-functions-core-tools
v4.0.6594 is the latest version available based on your source(s).
- nodejs-lts
v22.11.0 is the latest version available based on your source(s).
- azure-functions-core-tools
エラー
func start
Core Tools Version: 4.0.6518 Commit hash: N/A +74ed9095fdd6c5326276aae6b8a7d41ccbdeb6aa (32-bit)
Function Runtime Version: 4.35.4.23179
[2024-11-12T10:43:17.733Z] A host error has occurred during startup operation '67f3a649-ccf2-447a-b5f0-1be2ab709c2e'.
[2024-11-12T10:43:17.736Z] Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: node not found.
[2024-11-12T10:43:17.743Z] Failed to stop host instance '39ddecc7-82d2-4f6a-8dcd-d4fa95b372f8'.
[2024-11-12T10:43:17.743Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')
[2024-11-12T10:43:17.748Z] Host startup operation has been canceled
調査
$ func -v
4.0.6518
chocolateyでアンインストールして入れなおしてみる。
choco uninstall azure-functions-core-tools -y
choco install azure-functions-core-tools --params "'/x64:true'" -y
最新がダウンロードされているようだが、 func -v
は4.0.6518のまま。
Download of Azure.Functions.Cli.win-x64.4.0.6594.zip (395.63 MB) completed.
whereで確認したところ、C:\ProgramData\chocolatey\bin\func.exe
が使われているもよう。
$ func -v
4.0.6518
$ where func
C:\ProgramData\chocolatey\bin\func.exe
調べてみると、shimのファイルであった。
PS C:\Users> func -v --shimgen-log
[shim]: Set up Shim to run with the following parameters:
path to executable: C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\in-proc8\func.exe
Windows でソフトウェアを chocolatey で管理すると超絶便利になりそう によると、後勝ちらしい。
そういえば、ログには func.exeを作ったと3回出ていた。
You can opt-out of telemetry by setting the FUNCTIONS_CORE_TOOLS_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
ShimGen has successfully created a shim for func.exe
ShimGen has successfully created a shim for func.exe
ShimGen has successfully created a shim for func.exe
期待するfunc.exe
を指すようにshimgenを作りなおす。
c:\ProgramData\chocolatey\tools\shimgen.exe --output=c:\ProgramData\Chocolatey\bin\func.exe --path="C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\func.exe"
実行した結果はこちら。
PS C:\Users> c:\ProgramData\chocolatey\tools\shimgen.exe --output=c:\ProgramData\Chocolatey\bin\func.exe --path="C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\func.exe"
Microsoft (R) Visual C# Compiler version 4.8.9232.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.
This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
ShimGen has successfully created 'c:\ProgramData\Chocolatey\bin\func.exe'
PS C:\Users> func -v
4.0.6594
無事、4.0.6594に更新することができた。
Azure Functionsのエラーも解決し、func start
が行えるようになった。
参考
shim
shimgen
Can't find templates location. Looked under 'C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\in-proc8\templates\net-isolated'
Manually Shimming An Application Into the Chocolatey Path