--- title: "トリガー追加" slug: "cloudfunctions-example04" tags: ["Cloud Functions"] updated: 2026-09-17T09:31:52Z published: 2026-09-17T09:31:52Z canonical: "guide.ncloud-docs.com/cloudfunctions-example04" --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # トリガー追加 Classic/VPC環境で利用できます。 アクションを実行するトリガーを追加する方法を理解するのに役立つユースケースを紹介します。このユースケースは、ユーザーの位置を更新するトリガーを作成し、ユーザーの位置が更新されたときに helloアクションを呼び出す内容です。ユースケース学習の際は、以下のガイドをご参考ください。 - アクション作成方法 - Cloud Functions を使用する > Action > アクション作成 ## アクション作成 1. 名前と場所を受け取り、出力するソースコードを作成します。 ``` function main(params) { return {payload: 'Hello, ' + params.name + ' from ' + params.place}; } ``` 1. 1.で作成したソースコードを使用し、コンソールでアクションを作成します。 ![cloudfunctions-example04_v2_01_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudfunctions-example04_v2_01_ja.png?sv=2026-02-06&spr=https&st=2026-10-30T16%3A57%3A05Z&se=2026-10-30T17%3A57%3A05Z&sr=c&sp=r&sig=349CsEA%2BQ7LxyMzEt%2FMV6HHA%2F154IYkVw21wqw6FcUU%3D) ## トリガー追加 アクションを実行するトリガーを追加する手順は、次の通りです。 1. コンソールで作成した helloActionという名前のアクションを選択し、詳細情報に移動します。 ![cloudfunctions-example04_v2_02_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudfunctions-example04_v2_02_ja.png?sv=2026-02-06&spr=https&st=2026-10-30T16%3A57%3A05Z&se=2026-10-30T17%3A57%3A05Z&sr=c&sp=r&sig=349CsEA%2BQ7LxyMzEt%2FMV6HHA%2F154IYkVw21wqw6FcUU%3D) 2. トリガー項目の **[追加]** ボタンをクリックします。 3. 関連付け方法として **新規作成** を選択し、タイプとして **API Gateway** を選択します。 ![cloudfunctions-example04_v2_03_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudfunctions-example04_v2_03_ja.png?sv=2026-02-06&spr=https&st=2026-10-30T16%3A57%3A05Z&se=2026-10-30T17%3A57%3A05Z&sr=c&sp=r&sig=349CsEA%2BQ7LxyMzEt%2FMV6HHA%2F154IYkVw21wqw6FcUU%3D) 4. API Gatewayを介してアクションを呼び出す API Gatewayのエンドポイントを作成するための設定を行います。 ![cloudfunctions-example04_v2_04_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudfunctions-example04_v2_04_ja.png?sv=2026-02-06&spr=https&st=2026-10-30T16%3A57%3A05Z&se=2026-10-30T17%3A57%3A05Z&sr=c&sp=r&sig=349CsEA%2BQ7LxyMzEt%2FMV6HHA%2F154IYkVw21wqw6FcUU%3D) ## 実行結果確認 トリガーを実行し、アクションが正常に実行されたか確認できます。確認する手順は次の通りです。 1. API Gatewayエンドポイントを呼び出してアクションを実行します。詳しい実行方法は、[API Gatewayトリガーのトリガー実行](/docs/ja/cloudfunctions-apigateway-vpc#%ED%8A%B8%EB%A6%AC%EA%B1%B0%EC%8B%A4%ED%96%89)をご参照ください。 ``` curl -X POST -H "Content-Type: application/json" https://func.apigw.ntruss.com/api/v1/hello?blocking=true&result=true -d '{"name": "Cloud Functions", "place": "NAVER Cloud"}' ``` 1. アクション詳細情報の **モニタリング** タブのメニュー画面で、実行結果の詳細情報を確認します。最も最近発生したアクティベーション情報を確認してアクションの実行有無を確認し、トリガーにより実行されたアクションがパラメータを正常に処理するか確認します。 ![cloudfunctions-example04_v2_05_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudfunctions-example04_v2_05_ja.png?sv=2026-02-06&spr=https&st=2026-10-30T16%3A57%3A05Z&se=2026-10-30T17%3A57%3A05Z&sr=c&sp=r&sig=349CsEA%2BQ7LxyMzEt%2FMV6HHA%2F154IYkVw21wqw6FcUU%3D)