Gat*_*ndo 4 yaml google-cloud-platform google-cloud-functions
我尝试使用“--env-vars-file”标志部署 GCP 云函数并指定一个 YAML 文件来包含变量。我的“app-dev.yaml”YAML 文件如下所示:
runtime: python37
api_version: '1'
threadsafe: 'true'
env_variables:
VAR_1: 'var_1_value'
VAR_2: 'var_2_value'
VAR_3: 'var_3_value'
Run Code Online (Sandbox Code Playgroud)
我的 gcloud 函数部署如下所示:
gcloud functions deploy my_cloud_function --env-vars-file app-dev.yaml --runtime python37 --trigger-resource my-project.appspot.com --trigger-event google.storage.object.finalize
Run Code Online (Sandbox Code Playgroud)
现在,当我运行此命令时,我收到此错误:
gcloud 崩溃(ValidationError):字段值的预期类型,找到 {'VAR_1': 'var_1_value', 'VAR_2': 'var_2_value', 'VAR_3': 'var_3_value'} (类型
<type 'dict'>)
但根据这个 Google 示例, app-dev.yaml 格式应该没问题。
任何帮助表示赞赏。谢谢
您提供的链接引用了app.yamlApp Engine 中所需的文件,与此无关。
根据此处的Cloud Functions 文档,该.env.yaml文件应具有以下格式:
VAR_1: var_1_value
VAR_2: var_2_value
VAR_3: var_3_value
Run Code Online (Sandbox Code Playgroud)
小智 6
所有值都必须是字符串,例如:
错误值:
Run Code Online (Sandbox Code Playgroud)VAR_1: 3.1416
正确值:
Run Code Online (Sandbox Code Playgroud)VAR_1: "3.1416"
| 归档时间: |
|
| 查看次数: |
4453 次 |
| 最近记录: |