つばろぐ

主に C#, .NET, Azure の備忘録です。たまに日記。

Azure Storage Emulator 5.8.0.0でAzure Durable Functionsが実行できない問題を解消する方法

Azure Durable Functionsのアプリケーションをローカルで開発する場合、Azure Storage Emulatorを使うことを推奨されています。

docs.microsoft.com

docs.microsoft.com

エラーが起きた

しかし、2018/11/18時点で最新のAzure Storage Emulator 5.8.0.0では、Azure Durable Functionsの実行時(デバッグ含む)に下記のようなエラーが起きます。

Azure Functions Core Tools (2.2.32 Commit hash: c5476ae629a0a438d6850e58eae1f5203c896cd6)
Function Runtime Version: 2.0.12165.0
[2018/11/17 6:32:07] Building host: startup suppressed:False, configuration suppressed: False
[2018/11/17 6:32:07] Reading host configuration file 'D:\src\yuta\func\durable-functions-anti-pattarns\durable-functions-anti-pattarns\bin\Debug\netcoreapp2.1\host.json'
[2018/11/17 6:32:07] Host configuration file read:
[2018/11/17 6:32:07] {
[2018/11/17 6:32:07]   "version": "2.0"
[2018/11/17 6:32:07] }
[2018/11/17 6:32:34] A host error has occurred
[2018/11/17 6:32:34] Microsoft.WindowsAzure.Storage: Server encountered an internal error. Please try again after some time.

本来なら関数が読み込まれ実行エンドポイントが用意されるわけですが、「Microsoft.WindowsAzure.Storage: Server encountered an internal error. Please try again after some time.」となり、止まってしまいます。

原因

この問題に関して、すでにIssueが上がっています。

github.com

I think this might possibly be a problem with extensions that use web hooks.

Issueにはこのように記載されており、Webhook、つまりHTTPトリガーの関数で起きるだろうとのこと。
実際、私の環境でもHTTPトリガーの関数の実行時にエラーが発生しました。

対策

IssueはOpen状態のため根本解決には至ってないと思いますが、暫定的な対策が提示されています。
local.settings.jsonというローカル開発時の設定ファイルに "AzureWebJobsSecretStorageType": "files" を追記するようです。

初期状態のlocal.settings.jsonに追記した状態は下記になります。

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureWebJobsSecretStorageType": "files"
  }
}