简体   繁体   中英

Sending emails using sendgrid and Google cloud platform

I am trying to follow along with the instructions on how to send up SendGrid to send emails on GoogleCloudPlatform, and I am stuck. Here are a few things to know up front: The directions I am attempting to follow: https://cloud.google.com/functions/docs/tutorials/sendgrid#windows

I have made it down to the section: Understanding the code: importing the dependencies. Everything up until I think I have understood and completed. At this point it lists some NODE.JS code that has to be implemented.

This is where I am completely lost. I am not sure where to execute this code. Example:

const Buffer = require('safe-buffer').Buffer;
const sendgrid = require('sendgrid');
const config = require('./config.json');
const uuid = require('uuid');

// Get a reference to the Cloud Storage component
const storage = require('@google-cloud/storage')();
// Get a reference to the BigQuery component
const bigquery = require('@google-cloud/bigquery')();

This is a section of code it says to execute. But where? CMD prompt? a .bat file? somewhere on the google cloud platform? Functions? Storage? BigQuery?

I understand no JavaScript and even less Node.js and I hvae only been working with Google cloud platform for about a week and it is very confusing to me. (I am typically developing in T-SQL so all of this is foreign to me!)

I think I am looking for a very simplistic overview or direction to go in. I have not found much in the way of online help that I understand.

Bottom line of what I am looking to do is to automate a process that will run every night take some data out of a BigQuery view, insert it into a table, then export the contents of that table into a .csv file on the Google Cloud storage (This is the point I am at currently) From this point I am hoping to make a cloud function that will fire once this file hits the storage bucket and will generate an e-mail and send the .csv file as an attachment to some set recipients.

Any help or suggestions would be greatly appreciated. I am close to getting my first project in the google cloud platform completed!

It's all just one node JS file. You can see it here on Github in its entirety. Within this file are several functions. Each one that starts with exports. can be deployed as its own Cloud Function. You use the same file to deploy several Cloud Functions. In the section " Deploying the functions ", you'll see this happening:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM