Alias-related commands

更新时间:
复制 MD 格式

The FC component is a Serverless Devs-based CLI tool for Function Compute that lets you run interactive commands to manage service aliases. All commands call the Function Compute API directly using the prefix sudo s cli fc api.

Prerequisites

Before you begin, ensure that you have:

Create an alias

Syntax

sudo s cli fc api CreateAlias
    --region <region-id>
   [--access <access-name>]
   [--apiVersion <20210416|20160815>]
    --path '{"serviceName": "<service-name>"}'
   [--body '{"aliasName": "<alias-name>",
             "versionId": "<version-id>",
             "additionalVersionWeight": <weight-config>,
             "description": "<description>"}']

Parameters

ParameterRequiredDescription
--regionYesThe region where the service is deployed.
--access / -aNoThe alias of the AccessKey to use.
--apiVersionNoThe API version. Valid values: 20210416, 20160815.
--path.serviceNameYesThe name of the service.
--body.aliasNameNoThe name of the alias.
--body.versionIdNoThe version that the alias points to.
--body.additionalVersionWeightNoThe canary release version and its traffic weight. For example, {"2": 0.05} routes 5% of traffic to version 2.
--body.descriptionNoThe description of the alias.

Example

Create alias aliastest pointing to version 1 of service mytest in the cn-hangzhou region:

sudo s cli fc api CreateAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest"}' --body '{"aliasName": "aliastest","versionId": "1"}'

For more information, see CreateAlias.

Delete an alias

Syntax

sudo s cli fc api DeleteAlias
    --region <region-id>
   [--access <access-name>]
   [--apiVersion <20210416|20160815>]
    --path '{"serviceName": "<service-name>", "aliasName": "<alias-name>"}'

Parameters

ParameterRequiredDescription
--regionYesThe region where the service is deployed.
--access / -aNoThe alias of the AccessKey to use.
--apiVersionNoThe API version. Valid values: 20210416, 20160815.
--path.serviceNameYesThe name of the service.
--path.aliasNameYesThe name of the alias to delete.

Example

Delete alias aliastest from service mytest:

sudo s cli fc api DeleteAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest","aliasName": "aliastest"}'

For more information, see DeleteAlias.

Update an alias

Syntax

sudo s cli fc api UpdateAlias
    --region <region-id>
   [--access <access-name>]
   [--apiVersion <20210416|20160815>]
    --path '{"serviceName": "<service-name>", "aliasName": "<alias-name>"}'
   [--body '{"versionId": "<version-id>",
             "additionalVersionWeight": <weight-config>,
             "description": "<description>"}']

Parameters

ParameterRequiredDescription
--regionYesThe region where the service is deployed.
--access / -aNoThe alias of the AccessKey to use.
--apiVersionNoThe API version. Valid values: 20210416, 20160815.
--path.serviceNameYesThe name of the service.
--path.aliasNameYesThe name of the alias to update.
--body.versionIdNoThe version that the alias points to.
--body.additionalVersionWeightNoThe canary release version and its traffic weight. For example, {"2": 0.05} routes 5% of traffic to version 2.
--body.descriptionNoThe description of the alias.

Example

Route 5% of traffic to version 2 as a canary release, keeping 95% on the current stable version:

sudo s cli fc api UpdateAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest","aliasName": "aliastest"}' --body '{"additionalVersionWeight": {"2":0.05}}'

For more information, see UpdateAlias.

Get an alias

Syntax

sudo s cli fc api GetAlias
    --region <region-id>
   [--access <access-name>]
   [--apiVersion <20210416|20160815>]
    --path '{"serviceName": "<service-name>", "aliasName": "<alias-name>"}'

Parameters

ParameterRequiredDescription
--regionYesThe region where the service is deployed.
--access / -aNoThe alias of the AccessKey to use.
--apiVersionNoThe API version. Valid values: 20210416, 20160815.
--path.serviceNameYesThe name of the service.
--path.aliasNameYesThe name of the alias to query.

Example

Get details for alias aliastest in service mytest:

sudo s cli fc api GetAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest","aliasName": "aliastest"}'

For more information, see GetAlias.

List aliases

Syntax

sudo s cli fc api ListAliases
    --region <region-id>
   [--access <access-name>]
   [--apiVersion <20210416|20160815>]
    --path '{"serviceName": "<service-name>"}'
   [--query '{"limit": "<count>",
              "nextToken": "<token>",
              "prefix": "<name-prefix>",
              "startKey": "<start-key>"}']

Parameters

ParameterRequiredDescription
--regionYesThe region where the service is deployed.
--access / -aNoThe alias of the AccessKey to use.
--apiVersionNoThe API version. Valid values: 20210416, 20160815.
--path.serviceNameYesThe name of the service.
--query.limitNoThe maximum number of aliases to return.
--query.nextTokenNoThe pagination token from the previous response. Include this parameter to retrieve the next page of results. Omit it on the first call.
--query.prefixNoFilters results to aliases whose names start with this prefix.
--query.startKeyNoReturns aliases in alphabetical order starting from (and including) this key.

Example

List up to 3 aliases in service mytest:

sudo s cli fc api ListAliases --region cn-hangzhou --access default --path '{"serviceName": "mytest"}' --query '{"limit": "3"}'

For more information, see ListAliases.