简体   繁体   English

测试谷歌云 Function

[英]Test Google Cloud Function

Im asked to test a Google Cloud Function triggered by http through cloud shell using the "curl -m 60 -X GET [url_of_your_function]" commnand.我被要求使用“curl -m 60 -X GET [url_of_your_function]”命令测试由 http 通过云 shell 触发的 Google Cloud Function。

Does anyone know where to find the url of my function?有谁知道在哪里可以找到我的 function 的 url? Ive tried the main url of it and many other ideas but get not solution.我尝试了它的主要 url 和许多其他想法,但没有得到解决方案。 I cannot find any documentation on Google Cloud as documentation for GCF its very scarse and disorganized.我在 Google Cloud 上找不到任何文档作为 GCF 的文档,它非常稀疏且杂乱无章。

See Function URL on the documentation for Cloud Functions .请参阅Cloud Functions文档中的Function URL

The way to parse the describe result depends on whether you're using 1st or 2nd gen.解析describe结果的方式取决于您使用的是第一代还是第二代。

Once you have the URL, assuming it requires auth, you can:获得 URL 后,假设它需要身份验证,您可以:

ENDPOINT="$(gcloud functions describe ... )"
TOKEN="$(gcloud auth print-identity-token)"

curl \
--get \
--header "Authorization: Bearer ${TOKEN}" \
${ENDPOINT}

gcloud includes a command to invoke Cloud Functions directly too: gcloud包含一个直接调用 Cloud Functions 的命令:

gcloud functions call ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM