使用 Cloudrun for ENDPOINTS_SERVICE_NAME 环境变量时,Google Cloud Endpoints 收到错误

Hen*_*eng 1 google-cloud-platform google-cloud-endpoints-v2 google-cloud-run

使用 ESPv2 Beta sidecar 容器设置后端服务后收到以下错误消息。

Serverless ESPv2 expects ENDPOINTS_SERVICE_NAME in environment variables.

 Did you forget to build the Endpoints service configuration
 into the ESPv2 image? Please refer to the official serverless
 quickstart tutorials (below) for more information.

 https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-run#configure_esp
 https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions#configure_esp

 If you are following along with these tutorials but have not
 reached the step above yet, this error is expected. Feel free
 to temporarily disregard this error message.

 If you wish to skip this step, please specify the name of the
 service in the ENDPOINTS_SERVICE_NAME environment variable.
 Note this deployment mode is **not** officially supported.
 It is recommended that you follow the tutorials linked above.
Run Code Online (Sandbox Code Playgroud)

看起来我能够正确设置云运行服务,并能够直接从 API 获取响应。

审查它gcloud_build_image似乎没有变量。

https://github.com/GoogleCloudPlatform/esp-v2/blob/9a5a03d439867b0d5563081ac574e94d51922c32/docker/serverless/gcloud_build_image#L53

gui*_*ere 5

更新部署 Cloud Endpoint 的 Cloud Run 环境变量,如下所示

gcloud beta run services update <SERVICE NAME> \
--set-env-vars ENDPOINTS_SERVICE_NAME=<SERVICE NAME>-<hash>-<REGION>.a.run.app \
--region <REGION> --platform managed
Run Code Online (Sandbox Code Playgroud)

更详细的内容可以看我的文章