谷歌数据流 - 无效的区域端点 - 无法在来自 nodejs 客户端的模板上设置区域

ben*_*n.d 1 google-cloud-platform google-cloud-dataflow apache-beam

我有一个存储为模板的管道。我正在使用 node.js 客户端从云函数运行此管道。一切正常,但是当我需要从不同区域运行此模板时,我会出错。

根据文档,我可以通过payload中的location参数进行设置

{
  projectId: 123,
  resource: {
    location: "europe-west1",
    jobName: `xxx`,
    gcsPath: 'gs://xxx'
  }
}
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误:

The workflow could not be created, since it was sent to an invalid regional endpoint (europe-west1). 
Please resubmit to a valid Cloud Dataflow regional endpoint.
Run Code Online (Sandbox Code Playgroud)

如果我将位置参数移出资源节点,我会得到同样的错误,例如:

{
  projectId: 123,
  location: "europe-west1",
  resource: {
    jobName: `xxx`,
    gcsPath: 'gs://xxx'
  }
}
Run Code Online (Sandbox Code Playgroud)

如果我在环境中设置区域并删除位置,例如:

{
  projectId: 123,
  resource: {
    jobName: `xxx`,
    gcsPath: 'gs://xxx',
    environment: {
        zone: "europe-west1-b"
    }
   }
}
Run Code Online (Sandbox Code Playgroud)

我不再收到任何错误,但数据流 UI 告诉我作业正在运行 us-east1

如何运行此模板并提供区域/区域 I

Gui*_*ins 8

正如这里所解释的,实际上有两个端点:

要使 Dataflow 区域端点正常工作,必须使用第一个端点 ( dataflow.projects.locations.templates.launch)。这样,location请求中的参数将被接受。代码片段:

var dataflow = google.dataflow({
    version: "v1b3",
    auth: authClient
});

var opts = {
    projectId: project,
    location: "europe-west1",
    gcsPath: "gs://path/to/template",
    resource: {
        parameters: launchParams,
        environment: env
    }
};
dataflow.projects.locations.templates.launch(opts, (err, result) => {
    if (err) {
        throw err;
    }
    res.send(result.data);
});
Run Code Online (Sandbox Code Playgroud)