使用云功能执行数据流模板时出错

编程入门 行业动态 更新时间:2024-10-25 12:23:00
本文介绍了使用云功能执行数据流模板时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

尝试使用Google Cloud函数执行自定义数据流模板时遇到错误.

Getting below error while trying to execute custom dataflow template using Google Cloud function.

错误:问题正在运行的数据流模板,错误是:{错误:尝试检索Compute Engine内置服务帐户的访问令牌时,返回了禁止的错误.这可能是因为Compute Engine实例没有指定了正确的权限范围.无法刷新访问令牌".

Error:"problem running dataflow template, error was: { Error: A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified. Could not refresh access token".

我尝试提供所有必需的权限和范围.有人可以提出解决方案.

I have tried supplying all the required permissions and scopes.Could someone please suggest a resolution.

推荐答案

google-cloud 节点库尚不支持Dataflow API,因此当前使用该API的方法是 googleapis 库.

The google-cloud node library does not yet support the Dataflow API, so the current way to use that API is the googleapis library.

按照那里的说明,我尝试使用 Google提供的模板使用HTTP触发的功能,并且没有问题:

Following the instructions there, I've tried to launch a Dataflow job with a Google-provided template using an HTTP-triggered function, and had no issues:

const {google} = require('googleapis'); const project = "your-project-id" exports.launchDataflowTemplate = (req, res) => { let result; google.auth.getApplicationDefault(function(err, authClient, projectId) { if (err) { throw err; } if (authClient.createScopedRequired && authClient.createScopedRequired()) { authClient = authClient.createScoped([ 'www.googleapis/auth/cloud-platform', 'www.googleapis/auth/compute', 'www.googleapis/auth/compute.readonly', 'www.googleapis/auth/userinfo.email' ]); } var dataflow = google.dataflow({ version: "v1b3", auth: authClient }); var launchParams = { "inputFilePattern": "gs://your-input-bucket/*.gz", "outputDirectory": "gs://your-result-bucket/", "outputFailureFile": "gs://your-logs-bucket/error.csv" }; var env = { "tempLocation": "gs://your-staging-bucket/temp", "zone": "us-central1-f" } var opts = { projectId: project, gcsPath: "gs://dataflow-templates/latest/Bulk_Decompress_GCS_Files", resource: { parameters: launchParams, environment: env } }; dataflow.projects.templates.launch(opts, (err, result) => { if (err) { throw err; } res.send(result.data); }); }); };

更多推荐

使用云功能执行数据流模板时出错

本文发布于:2023-11-24 08:49:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据流   模板   功能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!