LoginSignup
0
0

Firebase Functionsへのデプロイが突然エラーになってはまった

Last updated at Posted at 2024-04-06

事象

FirebaseのFunctionsにaxiosで外部APIからデータを取得する関数を書いてデプロイしようとしたところ下記のエラーが発生した。
Could not create or update Cloud Run service 「関数名」, Container Healthcheck failed. Revision 'getinstagramdata-00004-pud' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.

原因

functionsにaxiosがインストールされていなかったという初歩的なオチでした。
axiosがないよ!というエラーはでないため、前述のエラーメッセージからは推測できず。

コード上にaxiosのimportが記述されていているのですが、プロジェクト本体にはaxiosはインストールされており、Functionsに別途インストールしなければいけないことに気づいていませんでした。

エラー文にPORT=8080に関する記述もあり、CloudRunのポート周りの設定を調べるなど、関係ないことに時間を費やしてしまいかなりハマりました。

解決方法

firebase init functions

で作成されたfunctionsディレクトリに移動してaxiosをインストール

npm i axios

その後下記でデプロイしたところ問題なく動作させることができました

firebase deploy --only functions
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