google-site-verification=EmVnnySXehAfTr_j8ZJN48hwvxJtfNf80pkPX1ObQlA Fast Track News: GSP081 Cloud Functions: Qwik Start - Console

GSP081 Cloud Functions: Qwik Start - Console

 REGION=



gcloud services enable run.googleapis.com

export PROJECT_ID=$(gcloud config list --format 'value(core.project)')

gcloud config set compute/region $REGION


mkdir ~/hello-https && cd $_

touch index.js && touch package.json


tee -a index.js <<EOF

/**

 * Responds to any HTTP request.

 *

 * @param {!express:Request} req HTTP request context.

 * @param {!express:Response} res HTTP response context.

 */

exports.helloWorld = (req, res) => {

  let message = req.query.message || req.body.message || 'Hello World!';

  res.status(200).send(message);

};

EOF



tee -a package.json <<EOF

{

  "name": "sample-http",

  "version": "0.0.1"

}

EOF




gcloud functions deploy GCFunction \

  --gen2 \

  --runtime nodejs18 \

  --entry-point helloWorld \

  --source . \

  --region $REGION \

  --trigger-http \

  --timeout 540s \

  --allow-unauthenticated \

  --max-instances 5



#-----------------IF YOU SEE ERROR > WAIT FOR 5 MINUTES > AND RERUN ABOVE COMMAND "gcloud functions deploy ..." ------------------


URL=https://$REGION-$PROJECT_ID.cloudfunctions.net/GCFunction

echo $URL


curl -m 70 -X POST $URL \

    -H "Authorization: bearer $(gcloud auth print-identity-token)" \

    -H "Content-Type: application/json" \

    -d '{"message":"Hello World!"}'


No comments:

Post a Comment

April Week 2 || Lab 2 || Troubleshooting Data Models in Looker

  CREATE NEW FILE NAME: user_order_lifetime view: user_order_lifetime { derived_table: { sql: SELECT order_items.user_id as us...