我正在使用以下 .yaml 文件通过 GitHub 和 Google Cloud Build 创建 CICD 管道:
# Cloud Function specifications
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- hello_world
- --source=./src
- --trigger-http
- --memory=1024MB
- --max-instances=5
- --runtime=python39
- --region=europe-west6
- --entry-point=predict
- --allow-unauthenticated
一切正常,功能部署正确;但是,每当我尝试调用它时,都会引发以下错误:
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>401 Unauthorized</title>
</head>
似乎 --allow-unauthenticated 参数无法正常工作。如何公开 API 并提供公共访问权限?
笔记:
如果我跑gcloud functions describe --project=XXXXXX --region=europe-west6 hello_world
我得到:
availableMemoryMb: 1024
buildId: 1234
entryPoint: predict
environmentVariables:
ABC: '"discount"'
httpsTrigger:
securityLevel: SECURE_OPTIONAL
url: https://europe-west6-XXX.cloudfunctions.net/hello_world
ingressSettings: ALLOW_ALL
labels:
deployment-tool: cli-gcloud
maxInstances: 5
name: projects/XXX/locations/europe-west6/functions/hello_world
runtime: python39
serviceAccountEmail: XXX@appspot.gserviceaccount.com
sourceUploadUrl: https://storage.googleapis.com/gcf-upload-europe-west6XXX
status: ACTIVE
timeout: 60s
updateTime: '2021-06-10T17:09:55.950Z'
versionId: '2'