You can use .NET Core to write functions in a custom container of Function Compute. This topic describes how to deploy and invoke a .NET Core function. You can also modify the .NET Core sample code as needed for custom development.
- Run the following command in the specified directory to initialize a project:
s init start-fc-custom-container-http-aspdotnetcore -d start-cc-http-aspdotnetcoreNote
-dspecifies the name of the folder in which the sample project resides. You can customize the folder name as required.
- Run the following command to go to the project directory:
- Optional: Modify the sample code as needed for custom development.
- Modify the s.yaml file. Change the value of the
imagefield in the s.yaml file to your image name.
- Run the following command to deploy the project:
s deploy -ySample command output:
[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
After the project is deployed, you can view the temporary domain name that is generated by Function Compute in the output. The temporary domain name can be used to access the newly deployed application. For example, run the following command to access the application:
curl -v http://aspdotnetcore-http-function.hello-world-service.188077086902****.cn-hangzhou.fc.devsapp.net