All Products
Search
Document Center

Function Compute:CreateAlias

Last Updated:Nov 06, 2024

Creates an alias.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
fc:CreateAliascreate
  • All Resources
    *
    none
none

Request syntax

POST /2021-04-06/services/{serviceName}/aliases HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
serviceNamestringYes

The name of the service.

service_name
bodyobjectNo

The definition of the alias.

additionalVersionWeightobjectNo

The canary release version to which the alias points and the weight of the canary release version.

  • The canary release version takes effect only when the function is invoked.
  • The value consists of a version number and the corresponding weight. For example, 2:0.05 indicates that Version 2 is the canary release version and 5% of traffic is directed to the canary release version when the function is invoked. 95% of traffic is directed to the main version.
floatNo

The traffic weight. Valid values: 0 to 1.

1
aliasNamestringYes

The name of the alias. The value can contain only letters, digits, underscores (_) and hyphens (-). It cannot start with a digit or hyphen (-). It must be 1 to 128 characters in length and cannot be LATEST.

alias_test
descriptionstringNo

The description of the alias.

test_description
versionIdstringYes

The ID of the version to which the alias points.

1
resolvePolicystringNo

The canary release mode. Valid values:

  • Random: random canary release.
  • Content: rule-based canary release. Default value: null.
Random
routePolicyRoutePolicyNo

The canary release rule. Traffic that meets the canary release rule is routed to the canary release instance.

X-Fc-Account-IdstringNo

The ID of your Alibaba Cloud account.

188077086902****
X-Fc-DatestringNo

The time on which the function is invoked. The format of the value is: EEE,d MMM yyyy HH:mm:ss GMT.

Wed, 11 May 2022 09:00:00 GMT
X-Fc-Trace-IdstringNo

The trace ID of the invocation request of Function Compute.

r9s89isisi****

Response parameters

ParameterTypeDescriptionExample
headersobject
etagstring

The ETag that is used to modify the alias. The value is used to ensure that the modified alias is consistent with the alias that is expected to be modified.

5e547e5605e1dc17a78a6191bc18fbc5
object

The definition of the alias.

additionalVersionWeightobject

The additional version to which the alias points and the weight of the additional version.

  • The additional version takes effect only when the function is invoked.
  • The value consists of a version number and a specific weight. For example, 2:0.05 indicates that when a function is invoked, Version 2 is the canary release version, 5% of the traffic is distributed to the canary release version, and 95% of the traffic is distributed to the major version.
float

The traffic weight. Valid values: 0 to 1.

1
aliasNamestring

The name of the alias.

alias_test
createdTimestring

The time when the alias was created.

2020-04-23T06:32:43Z
descriptionstring

The description of the alias.

test_description
lastModifiedTimestring

The time when the alias was last modified.

2020-04-23T06:32:43Z
versionIdstring

The ID of the version to which the alias points.

1
resolvePolicystring

The canary release mode. Default values: off. Valid values:

  • Random: random canary release.
  • Content: rule-based canary release.
Random
routePolicyRoutePolicy

The canary release rule. The traffic that meets the conditions of the canary release rule is diverted to the canary release instances.

Examples

Sample success responses

JSONformat

{
  "additionalVersionWeight": {
    "key": 1
  },
  "aliasName": "alias_test",
  "createdTime": "2020-04-23T06:32:43Z",
  "description": "test_description",
  "lastModifiedTime": "2020-04-23T06:32:43Z",
  "versionId": "1",
  "resolvePolicy": "Random",
  "routePolicy": {
    "condition": "AND",
    "policyItems": [
      {
        "type": "Header",
        "key": "x-test-uid",
        "value": "11111",
        "operator": "="
      }
    ]
  }
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-12-28The response structure of the API has changedView Change Details
2022-08-04The internal configuration of the API is changed, but the call is not affectedView Change Details
2021-06-29The request parameters of the API has changedView Change Details
2021-06-29The request parameters of the API has changedView Change Details
2021-06-29The request parameters of the API has changedView Change Details