Microsoft learn - Azure Functions と SignalR Service の部分ではまる

f:id:tworks55:20211212135210p:plain

「Azure Functions と SignalR Service を使って、Web アプリケーションの自動更新を有効にする」の演習 - ポーリングベースの Web アプリの制限事項を分析するで少しはまったので記録に残します。

演習の説明通りAzure Portalでの作業で環境構築し、ローカルでアプリケーションを動かしてみた所どうも株価が表示されませんでした。

1つ目の間違いはVS Codeで開いていたフォルダがstartフォルダになっておらず、F5でデバッグしてもAzure functionが動かなかったことです。 これはこちらを見て気が付きました。


そして次は以下のようなエラーが発生しました。

Azure Functions Core Tools
Core Tools Version:       4.0.3971 Commit hash: d0775d487c93ebd49e9c1166d5c3c01f3c76eaaf  (64-bit)
Function Runtime Version: 4.0.1.16815

[2021-12-12T04:44:48.999Z] Referenced bundle Microsoft.Azure.Functions.ExtensionBundle of version 1.8.1 does not meet the required minimum version of 2.6.1. Update your extension bundle reference in host.json to reference 2.6.1 or later.
[2021-12-12T04:44:49.007Z] A host error has occurred during startup operation '148a8334-9e73-4017-8cec-f8e03070d70f'.
[2021-12-12T04:44:49.008Z] Microsoft.Azure.WebJobs.Script: Referenced bundle Microsoft.Azure.Functions.ExtensionBundle of version 1.8.1 does not meet the required minimum version of 2.6.1. Update your extension bundle reference in host.json to reference 2.6.1 or later. For more information see https://aka.ms/func-min-bundle-versions.
Value cannot be null. (Parameter 'provider')

ターミナルはタスクで再利用されます、閉じるには任意のキーを押してください。

原因はAzure Functions Core Toolsのバージョン不一致と思われます。演習の説明には、

コンピューターに次のソフトウェアがインストールされていることを確認してください。

Node.js
Visual Studio Code
Azure Functions Core Tools (バージョン 2.6.666)
Visual Studio Code 用の Azure Functions 拡張機能
Visual Studio Code 用の Azure Storage 拡張機能

と記載されているのですがリンク先では

v1 (v1.x branch): Requires .NET 4.7.1 Windows Only
v2 (master branch): Self-contained cross-platform package
v3: (v3.x branch): Self-contained cross-platform package
v4: (v4.x branch): Self-contained cross-platform package (recommended)

となっており、v4をインストールしました。

その為、Azure Functions Core ToolsのバージョンがConfig設定と不整合となってしまったのだと思います。

これはこちらを見て気が付きました。




そこでhost.jsonに記載されているバージョンを以下に変更しました。("version": "[3.3.0, 4.0.0)"でも動きます)

{
  "version": "2.0",
  "extensionBundle": {
      "id": "Microsoft.Azure.Functions.ExtensionBundle",
      "version": "[2.*, 3.0.0)"
  }
}

開発者であれば、このあたりは自力で解決できるのだと思いますが、経験が少ないとちょっと厳しいかな。