0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure Functions 分離ワーカーモデルで BLOB trigger を準備する

Last updated at Posted at 2024-07-28

最近 Azure Functions の.NET 8 分離ワーカーモデルをよく触っているのですが、何気なく BLOB trigger を追加したところビルドが通らなくなりました。自分メモとして書き残しておきます。

やりたいこと

  • Azure Functions の .NET 8 分離ワーカーモデルで BLOB trigger をビルドする

あくまでプロジェクト作成時の準備です。

環境

  • Visual Studio Community 2022 Version 17.10.4
  • .NET 8
  • Azure Functions 分離ワーカーモデル

やったこと

Visual Studio で言われるがままに

  1. Azure Functions プロジェクトを追加(.NET 8 Isolated)
  2. 初期設定で BLOB trigger を追加(ウィザードに沿って設定)
  3. ビルドできない!

BlobTriggerAttribute が見つかりませんでした

自動で追加してくれたと思った NuGet パッケージが足りないようです。

手動で NuGet パッケージを追加

  1. インストール済のパッケージを最新に更新
  2. 関連しそうな Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs をインストール

分離ワーカーモデルでは Microsoft.Azure.Functions.Worker.Extensions.* のパッケージが使われるのでだいたいあたりが付きます。

ビルド成功

上記パッケージをインストールすることでビルドができるようになりました。インストール済みのパッケージをまずアップデートしないと最新版をインストールできいないので注意が必要です。
でもそのうち Visual Studio のアップデートで解決しそうですよね。

追記:デバッグ実行のためには…

デバッグ実行するために local.settings.json の修正が必要でした。

{
    "IsEncrypted": false,
    "Values": {
-        "AzureWebJobsStorage": "",
+        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
    }
}

プロジェクト作成時、ランタイムストレージアカウントに Azurite を使用する (AzureWebJobStorage) にチェックがついてないとここが空になるようです。


参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?