获取函数信息。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
fc:GetFunction |
get |
*全部资源
|
无 | 无 |
请求语法
GET /2021-04-06/services/{serviceName}/functions/{functionName} HTTP/1.1
路径参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| serviceName |
string |
是 |
服务的名称。 |
service_name |
| functionName |
string |
是 |
函数的名称。 |
function_name |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| qualifier |
string |
否 |
服务的版本 ID 或者别名。 |
demoQualifier |
| X-Fc-Account-Id |
string |
否 |
您的阿里云账号(主账号)ID。 |
188077086902**** |
| X-Fc-Date |
string |
否 |
函数的调用开始日期,格式为EEE,d MMM yyyy HH:mm:ss GMT。 |
Wed, 11 May 2022 09:00:00 GMT |
| X-Fc-Trace-Id |
string |
否 |
自定义请求 ID。 |
asdf**** |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
函数的定义。 |
||
| codeChecksum |
string |
函数代码包的 CRC-64 值。 |
2825179536350**** |
| codeSize |
integer |
系统返回的函数代码包的大小,单位 Byte。 |
421 |
| createdTime |
string |
函数的创建时间。 |
2020-04-01T08:15:27Z |
| description |
string |
函数的描述。 |
test_description |
| environmentVariables |
object |
为函数设置的环境变量,可以在函数中获取环境变量的值。更多信息,请参见环境变量。 |
|
|
string |
环境变量配置。 |
{"key":"value"} |
|
| functionId |
string |
系统为每个函数生成的 ID,全局唯一。 |
aa715851-1c20-4b89-a8fb-*** |
| functionName |
string |
函数的名称。 |
function_name |
| handler |
string |
函数执行的入口,更多信息,请参见函数入口。 |
index.handler |
| lastModifiedTime |
string |
函数上一次被更新的时间。 |
2020-04-01T08:15:27Z |
| memorySize |
integer |
函数的内存规格,单位为 MB,内存大小为 64 MB 的倍数。不同的函数实例类型,内存规格存在差异。更多信息,请参见实例规格。 |
256 |
| runtime |
string |
函数运行的语言环境。当前支持 nodejs20、nodejs18、nodejs16、nodejs14、nodejs12、nodejs10、nodejs8、nodejs6、nodejs4.4、python3.10、python3.9、python3、python2.7、java11、java8、go1、php7.2、dotnetcore2.1、custom.debian10、custom 和custom-container。 |
python3 |
| timeout |
integer |
函数运行的超时时间,单位为秒,默认 60 秒。最小 1 秒,最长 10 分钟。如果函数运行超过设置的时间,函数运行将被终止。 |
60 |
| initializationTimeout |
integer |
初始化函数运行的超时时间,单位为秒,默认 3 秒。最小 1 秒,最长 5 分钟。初始化函数超过这个时间后会被终止执行。 |
60 |
| initializer |
string |
初始化函数执行的入口,具体格式与语言相关,更多信息,请参见 Initializer 函数。 |
index.handler |
| caPort |
integer |
Custom Runtime 或 Custom Container 运行时 HTTP Server 的监听端口。 |
9000 |
| customContainerConfig | CustomContainerConfigInfo |
Custom Container 运行时的相关配置,配置后函数可以使用自定义容器镜像执行函数。 |
|
| layers |
array |
层的列表(ARN V1 版本)。 说明
多个层会按照数组下标从大到小的顺序进行合并,下标小的层的内容会覆盖下标大的层的同名文件。 警告 该参数待废弃,请使用 layersArnV2。 |
|
|
string |
层资源的名称(ARN V1 版本)。 |
02f81d283888f5ec63442a88fe82b260#Layer-name#1 |
|
| instanceConcurrency |
integer |
单个函数实例的并发度。 |
10 |
| instanceSoftConcurrency |
integer |
实例软并发度,用于优雅扩容。当实例上的并发数超过软并发度时,会触发实例扩容。例如,您的实例启动较慢,可以通过设置合适的软实例并发度,提前启动实例。 取值小于或等于 instanceConcurrency。 |
5 |
| instanceType |
string |
函数的实例类型,取值如下:
|
e1 |
| instanceLifecycleConfig |
InstanceLifecycleConfig |
实例生命周期配置。 |
|
| customDNS | CustomDNS |
函数自定义 DNS 配置。 |
|
| customRuntimeConfig | CustomRuntimeConfig |
Custom Runtime 函数详细配置。 |
|
| customHealthCheckConfig | CustomHealthCheckConfig |
函数自定义健康检查配置,仅适用于 Custom Runtime 和 Custom Container。 |
|
| layersArnV2 |
array |
层的列表(ARN V2 版本)。 说明
多个层会按照数组下标从大到小的顺序进行合并,下标小的层的内容会覆盖下标大的层的同名文件。 |
|
|
string |
层资源的名称(ARN V2 版本)。 |
acs:fc:{region}:{accountID}:layers/{layerName}/versions/{layerVersion} |
|
| cpu |
number |
函数的 CPU 规格,单位为 vCPU,为 0.05 vCPU 的倍数。 |
1.5 |
| diskSize |
integer |
函数的磁盘规格,单位为 MB,可选值为 512 MB 或 10240 MB。 |
512 |
| gpuMemorySize |
integer |
function 的 GPU 显存规格,单位为 MB,为 1024MB 的倍数 |
2048 |
示例
正常返回示例
JSON格式
{
"codeChecksum": "2825179536350****",
"codeSize": 421,
"createdTime": "2020-04-01T08:15:27Z",
"description": "test_description",
"environmentVariables": {
"key": "{\"key\":\"value\"}"
},
"functionId": "aa715851-1c20-4b89-a8fb-***",
"functionName": "function_name",
"handler": "index.handler",
"lastModifiedTime": "2020-04-01T08:15:27Z",
"memorySize": 256,
"runtime": "python3",
"timeout": 60,
"initializationTimeout": 60,
"initializer": "index.handler",
"caPort": 9000,
"customContainerConfig": {
"args": "[\"-arg1\", \"value1\"]",
"command": "[\"/code/myserver\"]",
"image": "registry-vpc.cn-hangzhou.aliyuncs.com/fc-demo/helloworld:v1beta1",
"accelerationType": "Default",
"accelerationInfo": {
"status": "Preparing"
},
"instanceID": "cri-xxxxxxxxxx",
"webServerMode": true
},
"layers": [
"02f81d283888f5ec63442a88fe82b260#Layer-name#1"
],
"instanceConcurrency": 10,
"instanceSoftConcurrency": 5,
"instanceType": "e1",
"instanceLifecycleConfig": {
"preFreeze": {
"handler": "index.preStop",
"timeout": 10
},
"preStop": {
"handler": "index.preStop",
"timeout": 10
}
},
"customDNS": {
"nameServers": [
"8.8.x.x"
],
"searches": [
"ns1.svc.cluster-domain.example"
],
"dnsOptions": [
{
"name": "ndots",
"value": "2"
}
]
},
"customRuntimeConfig": {
"command": [
"/code/myBootstrap"
],
"args": [
"args1"
]
},
"customHealthCheckConfig": {
"httpGetUrl": "/ready",
"initialDelaySeconds": 1,
"periodSeconds": 1,
"timeoutSeconds": 2,
"failureThreshold": 1,
"successThreshold": 2
},
"layersArnV2": [
"acs:fc:{region}:{accountID}:layers/{layerName}/versions/{layerVersion}"
],
"cpu": 1.5,
"diskSize": 512,
"gpuMemorySize": 2048
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。