谷歌云功能命令打包而不部署 [英] google cloud functions command to package without deploying
问题描述
我必须缺少一些东西,因为我在这里找不到此选项:https://cloud.google.com/sdk/gcloud/reference/beta/functions/deploy
I must be missing something because I cant find this option here: https://cloud.google.com/sdk/gcloud/reference/beta/functions/deploy
我想打包并将我的函数上传到存储桶:-stage-bucket
但实际上并未部署该功能
I want to package and upload my function to a bucket: --stage-bucket
But not actually deploy the function
我将使用Deployment Manager模板从同一软件包中部署多个功能(不同的处理程序): type:'gcp-types/cloudfunctions-v1:projects.locations.functions'
I'm going to deploy multiple functions (different handlers) from the same package with a Deployment Manager template: type: 'gcp-types/cloudfunctions-v1:projects.locations.functions'
gcloud beta函数部署
坚持打包和部署该函数. gcloud beta功能包
命令在哪里?
gcloud beta functions deploy
insists on packaging AND deploying the function.
Where is the gcloud beta functions package
command?
以下是我计划运行的DM模板的示例:
Here is an example of the DM template I plan to run:
resources:
- name: resource-name
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions'
properties:
labels:
testlabel1: testlabel1value
testlabel2: testlabel2value
parent: projects/my-project/locations/us-central1
location: us-central1
function: function-name
sourceArchiveUrl: 'gs://my-bucket/some-zip-i-uploaded.zip'
environmentVariables:
test: '123'
entryPoint: handler
httpsTrigger: {}
timeout: 60s
availableMemoryMb: 256
runtime: nodejs8
我意识到我还有另一个问题.当我上传一个zip时,该zip是否需要包含依赖项?我是否必须先进行npm install或pip install并将这些软件包包括在zip中,或者云功能会读取我的requirements.txt和packages.json并为我这样做?
I realized I have another question. When I upload a zip does that zip need to include dependencies? Do I have to do npm install or pip install first and include those packages in the zip or does cloud functions read my requirements.txt and packages.json and do that for me?
推荐答案
SDK CLI不提供打包功能的命令.
The SDK CLI does not provide a command to package your function.
此链接将为您提供有关如何将文件压缩在一起的详细信息.仅需注意两点:
This link will provide you with detail on how to zip your files together. There are just two points to follow:
- 文件类型应为zip文件.
- 文件大小不能超过100MB.
然后,您需要调用 API,它会返回一个签名URL来上传软件包.
Then you need to call an API, which returns a Signed URL to upload the package.
上传后,您可以指定URL减去多余的参数作为位置.
Once uploaded you can specify the URL minus the extra parameters as the location.
这篇关于谷歌云功能命令打包而不部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!