1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Posted at

はじめに

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)

参考

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?