通过函数计算的Custom Container,您可以使用.NET Core在函数计算平台编辑函数。本文介绍如何快速部署和调用.NET Core函数。您也可以按需修改.NET Core的示例代码实现二次开发。
操作步骤
- 在目标目录中,执行以下命令,初始化项目。
s init start-fc-custom-container-http-aspdotnetcore -d start-cc-http-aspdotnetcore
说明 -d
用于指定该示例项目文件夹的名称,支持自定义。
- 执行以下命令,进入项目目录。
cd start-cc-http-aspdotnetcore
- 可选:按需修改函数的示例代码,实现二次开发。
- 修改s.yaml文件。
将s.yaml文件内的image
字段的参数值修改为您的镜像名称。
- 执行以下命令,部署项目。
s deploy -y
输出示例:
[2022-02-09 07:25:48] [INFO] [S-CLI] - Start the pre-action
......
helloworld:
region: cn-hangzhou
service:
name: hello-world-service
function:
name: aspdotnetcore-http-function
runtime: custom-container
handler: not-used
memorySize: 512
timeout: 60
url:
system_url: https://188077086902****.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/hello-world-service/aspdotnetcore-http-function/
custom_domain:
-
domain: http://aspdotnetcore-http-function.hello-world-service.188077086902****.cn-hangzhou.fc.devsapp.net
triggers:
-
type: http
name: httpTrigger
执行结果
成功部署该项目后,您可以在执行输出中查看到函数计算生成的临时域名,通过该临时域名可以访问刚部署的应用,例如执行以下命令访问应用:
curl -v http://aspdotnetcore-http-function.hello-world-service.188077086902****.cn-hangzhou.fc.devsapp.net
说明 临时域名仅用作演示以及开发,具有时效性。如需用作生产,请绑定已经在阿里云备案的域名。详细信息,请参见
配置自定义域名。