如何克隆函数计算的函数?

更新时间:
复制 MD 格式

本文介绍如何通过Serverless Devs工具克隆函数。

前提条件

操作步骤

  1. 执行以下命令克隆测试函数sync-test
    s cli fc sync --region cn-hangzhou --service-name sync-test --function-name sync-test -a default
    克隆完成后,您可以看到函数已被克隆到本地当前目录。
    [root@iZbp1fufb1pctjjxxx]# s cli fc sync --region cn-hangzhou --service-name sync-test --function-name sync-test -a default
    ✓ devsapp_fc-sync.zip file decompression completed
    ✓ devsapp_fc-common.zip file decompression completed
    [2023-01-09 18:03:59] [INFO] [FC-SYNC] - sync code to /root/16490154655xxx_cn-hangzhou_sync-test_sync-test
    ✓ 16490154655xxx_cn-hangzhou_sync-test_sync-test.zip file decompression completed
    You can deploy the latest configuration of your sync through the [s exec -t /root/s.yaml -- sync] command.
    codeFiles:
      sync-test: /root/16490154655xxx_cn-hangzhou_sync_test_sync-test
    configYmlPath: /root/s.yaml
  2. 修改工作目录下的s.yaml文件,服务名称修改为sync-test,函数名称修改为sync-clone,然后执行以下命令部署函数。
    function:
      description: hello world by serverless devs
      runtime: nodejs14
      handler: index.handler
      timeout: 60
      memorySize: 128
      environmentVariables: {}
      instanceConcurrency: 1
      instanceType: e1
      name: sync-clone
      codeUri: /root/16490154655xxx_cn-hangzhou_sync_test_sync_test
    s deploy
    执行完成后,您可以登录函数计算控制台查看已克隆的函数。在函数列表中,可以看到已克隆生成的函数 sync-clone,其运行环境与源函数 sync-test 一致,均为 Node.js 14 / 128 MB / 0.08 vCPU。