Ondemand commands

You can use the ondemand command to manage on-demand resources of Function Compute.

Command description

You can run the ondemand -h or ondemand --help command to query the help information.

The ondemand command consists of three subcommands:

ondemand get command

The ondemand get command is used to query the details of specified on-demand resources.

You can run the ondemand get -h or ondemand get --helpcommand to query the help information.

Parameters decription

Full nameAbbreviationRequired in YAML modeRequired in CLI modeDescription
region-NoYesThe region. Valid values: cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, and ap-south-1.
service-name-NoYesThe name of the service.
function-name-NoYesThe name of the function.
qualifier-YesYesThe version. You can specify LATEST or an alias.

The current command also supports some global parameters (such as -a/--access, --debug, etc.). For details, please refer to Serverless Devs global parameters document

Examples

  • If a YAML resource description file exists, you can run the s ondemand get --qualifier qualifier command to obtain the details of on-demand resources based on a specified version.

  • If no YAML file exists and you use the command-line interface (CLI) mode, you must specify the region and name of the service. Example: s cli fc ondemand get --region cn-hangzhou --service-name fc-deploy-service --qualifier qualifier;

Sample output:

fc-deploy-test: 
  serviceName:          fc-deploy-service
  functionName:         http-trigger-py36
  qualifier:            LATEST
  resource:             services/fc-deploy-service.http-trigger-py36/functions/LATEST
  maximumInstanceCount: 1

ondemand list command

The ondemand list command is used to query the lists of on-demand resources.

You can run the ondemand list -h or ondemand list --help command to query the help information

Parameters description

Full nameAbbreviationRequired in YAML modeRequired in CLI modeDescription
region-NoYesThe region. Valid values: cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, and ap-south-1.
service-name-NoYesThe name of the service.
table-NoNoExports the query results in a table.

The current command also supports some global parameters (such as -a/--access, --debug, etc.). For details, please refer to Serverless Devs global parameters document

Examples

  • If a YAML resource description file exists, you can run the s ondemand list command to query the lists of on-demand resources.
  • If no YAML file exists and you use the CLI mode, you must specify the region and name of the service. Example: s cli fc ondemand list --region cn-hangzhou --service-name fc-deploy-service

Sample output:

fc-deploy-test: 
  - 
    serviceName:          fc-deploy-service
    qualifier:            http-trigger-py36
    functionName:         LATEST
    resource:             services/fc-deploy-service.http-trigger-py36/functions/LATEST
    maximumInstanceCount: 1

Sample output if you specify the --table parameter:

  ┌───────────────────┬───────────────────┬──────────────┬──────────────────────┐
  │    serviceName    │     qualifier     │ functionName │ maximumInstanceCount │
  ├───────────────────┼───────────────────┼──────────────┼──────────────────────┤
  │ fc-deploy-service │ http-trigger-py36 │ LATEST       │ 1                    │
  └───────────────────┴───────────────────┴──────────────┴──────────────────────┘

ondemand put command

The ondemand put command is used to publish or update an alias.

You can run the ondemand put -h or ondemand put --help command to query the help information.

Parameters description

Full nameAbbreviationRequired in YAML modeRequired in CLI modeDescription
region-NoYesThe region. Valid values: cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, and ap-south-1.
service-name-NoYesThe name of the service.
function-name-NoNoThe name of the function.
qualifier-YesYesThe version. You can specify LATEST or an alias.
max-YesYesThe maximum number of instances.

The current command also supports some global parameters (such as -a/--access, --debug, etc.). For details, please refer to Serverless Devs global parameters document

Examples

  • If a YAML resource description file exists, you can run the s ondemand put --qualifier qualifier command to configure on-demand resources.
  • If no YAML file exists and you use the CLI mode, you must specify the service name, the service region, and the function name. Example: s cli fc ondemand put --qualifier LATEST --max 1.

Sample output:

fc-deploy-test: 
  resource:             services/fc-deploy-service.http-trigger-py36/functions/LATEST
  maximumInstanceCount: 1

Permissions and policies

  • The AliyunFCReadOnlyAccess permission policy is required to run the ondemand list or ondemand get command.

  • The following permission policy is required to run the ondemand put command:

    {
        "Version": "1",
        "Statement": [
            {
                "Action": "fc:PutFunctionOnDemandConfig",
                "Effect": "Allow",
                "Resource": "acs:fc:<region>:<account-id>:services/services/<serviceName>.<qualifier>/functions/<functionName>"
            }
        ]
    }
    
Edit this page on GitHub Updated at Wed, Sep 21, 2022