这与以下 2 个线程相关: Google 云函数 - 无法读取属性“getApplicationDefault” 从云函数触发云数据流管道 - 函数超时
我创建了一个数据流模板,它将数据从 GCS 复制到 BigQuery,作为这两个示例。
作为初始化过程的一部分,我运行
npm init
npm install --save googleapis
Run Code Online (Sandbox Code Playgroud)
这是我的index.js
var {google} = require('googleapis');
exports.goWithTheDataFlow = (event, callback) => {
const file = event.data;
const context = event.context;
console.log(`Event ${context.eventId}`);
console.log(` Event Type: ${context.eventType}`);
console.log(` Bucket: ${file.bucket}`);
console.log(` File: ${file.name}`);
console.log(` Metageneration: ${file.metageneration}`);
console.log(` Created: ${file.timeCreated}`);
console.log(` Updated: ${file.updated}`);
google.auth.getApplicationDefault(function (err, authClient, projectId) {
if (err) {
throw err;
}
console.log(projectId);
const dataflow = google.dataflow({ version: 'v1b3', auth: …Run Code Online (Sandbox Code Playgroud) google-cloud-platform google-cloud-dataflow google-cloud-functions