Firebase云函数第二代中的不可预测的URL。

huangapple go评论56阅读模式
英文:

Unpredictable URLs with Firebase Cloud Functions 2nd gen

问题

我习惯于使用Firebase Functions,现在尝试使用Firebase Cloud Functions第2代来设置项目。

当我部署我的函数时,它们不会获得我从第1代了解的可预测URL(例如:https://europe-west1-[project-slug].cloudfunctions.net/[function-name]),而是一些奇怪的URL,比如这个:https://[function-name]-kbnn7zbc7q-uc.a.run.app)。

我在文档中找不到任何提及此问题的内容,我预计可能有一些设置可以获得更可预测的函数URL方案?

英文:

I am used to Firebase Functions and now trying to set up a project with Firebase Cloud Functions 2nd Gen.

When I deploy my functions they do not get the predictable URLs that I know from 1st gen (like: https://europe-west1-[project-slug].cloudfunctions.net/[function-name]), but rather some weird URLs like this one: https://[function-name]-kbnn7zbc7q-uc.a.run.app).

I can't find any mentions of this in the documentation and I expect there may be a setting to get a more predictable scheme for functions URLs?

答案1

得分: 4

目前还没有这样的选项。Cloud Functions 第二代实际上是构建在另一个云服务 Cloud Run 之上的。您看到的 URL 是 Cloud Run URL(注意 run.app)。

GCP Cloud Functions 文档中提到了这个 URL。特别是在这个教程中,它说:

> 注意:目前,Cloud Functions(第二代)中的函数 URL 使用非确定性格式,这意味着您无法在部署之前预测函数的 URL,尽管 URL 在部署后保持稳定。在将来的发布中,函数 URL 将被更新为稳定且确定性的。

同样在gcloud文档中也有:

> 注意:目前,Cloud Functions(第二代)中的函数 URL 使用非确定性格式,这意味着您无法在部署之前预测函数的 URL,尽管 URL 在部署后保持稳定。在将来的发布中,函数 URL 将被更新为稳定且确定性的。

Firebase 只是使用底层的 GCP 产品,因此继承了生成的 URL 的相同属性。

英文:

There is currently no such option. Cloud Functions 2nd gen is actually built on top of another cloud service called Cloud Run. The URL you're seeing is a Cloud Run URL (note run.app).

There are mentions in GCP Cloud Functions doc about this URL. In particular, in this tutorial, it says:

> Note: Currently, function URLs in Cloud Functions (2nd gen) use a non-deterministic format, meaning you cannot predict your function URL before deployment, though the URL remains stable after deployment. In a future release, function URLs will be updated to be both stable and deterministic.

Also in gcloud docs:

> Note: Currently, function URLs in Cloud Functions (2nd gen) use a non-deterministic format, meaning you cannot predict your function URL before deployment, though the URL remains stable after deployment. In a future release, function URLs will be updated to be both stable and deterministic.

Firebase just uses the underlying GCP products, so it inherits the same properties of the generated URL.

答案2

得分: 0

以下是已翻译的内容:

"截止目前,函数还有一个确定性的URL。

教程中提到:

一代和二代函数都分配了以下格式的URL。这些URL具有确定性格式,这意味着您可以在部署函数之前预测URL会是什么:

https://REGION-PROJECT_ID.cloudfunctions.net/FUNCTION_NAME

Firebase(不够明确地)显示非确定性URL。如果您和我一样不完全信任上述URL模式,可以在函数的GCP控制台中查看确定性URL。

英文:

As of now at least, there is also a deterministic URL for functions.

The tutorial adds this:

> Both 1st gen and 2nd gen functions have assigned URLs that have the following format. These URLs have a deterministic format, meaning that you can predict what the URL will be before you deploy the function:

https://REGION-PROJECT_ID.cloudfunctions.net/FUNCTION_NAME

Firebase (unhelpfully) shows the non-deterministic URL. You can see the deterministic URL in the GCP console for functions if you are like me and don't completely trust the URL pattern above.

huangapple
  • 本文由 发表于 2023年5月22日 20:56:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76306434.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定