You can call this operation to create a service.

Request headers

This operation uses only common request headers. For more information, see Common parameters.

Request syntax

POST /services 

Request parameters

Parameter Type Position Required Example Description
description String Body No test_description

The description of the service.

internetAccess Boolean Body No true

Specifies whether to allow functions to access the Internet. Valid values:

  • true
  • false
logConfig LogConfig Body No

The log configuration. This parameter specifies a Logstore to store function execution logs.

nasConfig NASConfig Body No

The Apsara File Storage NAS (NAS) file system configuration, which enables a function to access the specified NAS file system.

role String Body No acs:ram::19861****3743:role/fc-public-test

The RAM role that is used to grant required permissions to Function Compute. The role is used in the following scenarios:

  • Sends logs generated by a function to your Logstore.
  • Generates a token for a function to access other cloud resources during function execution.
serviceName String Body Yes service_name

The name of the service.

vpcConfig VPCConfig Body No

The VPC configuration, which enables a function to access the specified VPC.

tracingConfig TracingConfig Body No

The configuration of Tracing Analysis. After Function Compute integrates with Tracing Analysis, you can record the stay time of a request in Function Compute, view the cold start time for a function, and record the execution time of a function. For more information, see Tracing analysis.

Response parameters

Parameter Type Example Description
ETag String e19d5cd5af0378da05f63f891c7467af

The ETag value of the service name. This value is used to ensure that the modified service is consistent with the service to be modified.

createdTime String 2020-04-03T05:57:28Z

The time when the service was created.

description String test_description

The description of the service.

internetAccess Boolean true

Indicates whether functions were allowed to access the Internet. Valid values:

  • true
  • false
lastModifiedTime String 2020-04-03T05:57:28Z

The last time when the service was updated.

logConfig LogConfig

The log configuration. Function Compute writes function execution logs to the configured Logstore.

nasConfig NASConfig

The configuration of Apsara File Storage NAS (NAS) file system, which enables a function to access the specified NAS file system.

role String acs:ram::19861****3743:role/fc-public-test

The RAM role that is used to grant required permissions to Function Compute. The role is used in the following scenarios:

  • Sends logs generated by a function to your Logstore.
  • Generates a token for a function to access other cloud resources during function execution.
serviceId String c910061f-****-44e6-b659-***c

The ID generated by the system for the service, which is unique in Function Compute.

serviceName String service_name

The name of the service.

vpcConfig VPCConfig

The VPC configuration, which enables a function to access the specified VPC.

tracingConfig TracingConfig

The configuration of Tracing Analysis. After Function Compute integrates with Tracing Analysis, you can record the stay time of a request in Function Compute, view the cold start time for a function, and record the execution time of a function. For more information, see Tracing analysis.

Examples

Sample requests

POST /2016-08-15/services HTTP/1.1
Common request headers
{
    "serviceName":"service_name",
    "description":"test_description",
    "role":"acs:ram::19861****3743:role/fc-public-test",
    "logConfig":{
        "enableRequestMetrics":"true",
        "project":"test_project",
        "logstore":"test_logstore"
    },
    "serviceId":"c910061f-f6fa-44e6-b659-***c",
    "createdTime":"2020-04-03T05:57:28Z",
    "lastModifiedTime":"2020-04-03T05:57:28Z",
    "tracingConfig":{
        "params":{
            "endpoint":"http://tracing-*********-dc-sh-internal.aliyuncs.com/*****_iioe7jcnuk@***************_iioe7*****@******d2afe****/api/traces"
        },
        "type":"Jaeger"
    },
    "vpcConfig":{
        "vpcId":"vpc_***",
        "vSwitchIds":[
            "vsw_***"
        ],
        "securityGroupId":"sg-bp18hj1wtxgy3***",
        "role":"acs:ram::19861****3743:role/fc-public-test"
    },
    "internetAccess":true,
    "nasConfig":{
        "userId":100,
        "groupId":100,
        "mountPoints":[
            {
                "serverAddr":"***-uni85.cn-hangzhou.nas.aliyuncs.com:/",
                "mountDir":"/home/test"
            }
        ]
    },
    "vendorConfig":null
}

Sample success responses

JSON format

HTTP/1.1 200
ETag:e19d5cd5af0378da05f63f891c7467af
Content-Type:application/json
HTTP/1.1 200 OK
Common response headers
{
  "serviceName": "service_name",
  "description": "test_description",
  "role": "acs:ram::19861****3743:role/fc-public-test",
  "logConfig": {
    "enableRequestMetrics": "true",
    "project": "test_project",
    "logstore": "test_logstore"
  },
  "serviceId": "c910061f-f6fa-44e6-b659-***c",
  "createdTime": "2020-04-03T05:57:28Z",
  "lastModifiedTime": "2020-04-03T05:57:28Z",
  "tracingConfig": {
    "params": {
      "endpoint": "http://tracing-*********-dc-sh-internal.aliyuncs.com/*****_iioe7jcnuk@***************_iioe7*****@******d2afe****/api/traces"
    },
    "type": "Jaeger"
  },
  "vpcConfig": {
    "vpcId": "vpc_***",
    "vSwitchIds": [
      "vsw_***"
    ],
    "securityGroupId": "sg-bp18hj1wtxgy3***",
    "role": "acs:ram::19861****3743:role/fc-public-test"
  },
  "internetAccess": true,
  "nasConfig": {
    "userId": 100,
    "groupId": 100,
    "mountPoints": [
      {
        "serverAddr": "***-uni85.cn-hangzhou.nas.aliyuncs.com:/",
        "mountDir": "/home/test"
      }
    ]
  },
  "vendorConfig": null
}