0
Help us understand the problem. What are the problem?

posted at

Organization

azuriteを使ってローカルでtimer triggerを起動する

はじめに

TimerTriggerをローカルで動かそうかなと思っていたらこんなエラーがでました。

Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than httptrigger, kafkatrigger, orchestrationTrigger, activityTrigger, entityTrigger. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in local.settings.json.

functionsがAzureにある場合はlocal.settings.jsonをfetch-app-settingsを使って取得することでAzureWebJobsStorageの情報が設定されます。

ローカルで動かしている段階では大抵Azureにリソースはないと思います。

解決策

azuriteをインストールします。

npm install -g azurite

azuriteを起動します

$ azurite --silent --location /products/azurite --debug /products/azurite/debug.log
Azurite Blob service is starting at http://127.0.0.1:10000
Azurite Blob service is successfully listening at http://127.0.0.1:10000
Azurite Queue service is starting at http://127.0.0.1:10001
Azurite Queue service is successfully listening at http://127.0.0.1:10001
Azurite Table service is starting at http://127.0.0.1:10002
Azurite Table service is successfully listening at http://127.0.0.1:10002

BlobService,QueueService,TableServiceがそれぞれのポートで起動します。

あとはlocal.settings.jsonでazuriteを見るように修正します

local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true"
  }
}

functionsをローカルで起動します。

$ func start

Azure Functions Core Tools
Core Tools Version:       3.0.3442 Commit hash: 6bfab24b2743f8421475d996402c398d2fe4a9e0  (64-bit)
Function Runtime Version: 3.0.15417.0


Functions:

        export: timerTrigger

For detailed output, run func with --verbose flag.
[2021-05-18T02:40:04.799Z] Worker process started and initialized.
[2021-05-18T02:40:10.063Z] Host lock lease acquired by instance ID '0000000000000000000000005FB90853'.
[2021-05-18T02:45:00.072Z] Executing 'Functions.export' (Reason='Timer fired at 2021-05-18T11:45:00.0412924+09:00', Id=ff122567-13fe-46e8-81e0-948ac19ff6e0)
[2021-05-18T02:45:00.152Z] Timer trigger function ran! 2021-05-18T02:45:00.141Z
[2021-05-18T02:45:00.190Z] Executed 'Functions.export' (Succeeded, Id=ff122567-13fe-46e8-81e0-948ac19ff6e0, Duration=141ms)

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?