--- title: ".Net" slug: "cloudfunctions-example-net" tags: [".Net", "Cloud Functions"] updated: 2026-09-17T09:09:21Z published: 2026-09-17T09:09:21Z canonical: "guide-fin.ncloud-docs.com/cloudfunctions-example-net" --- > ## Documentation Index > Fetch the complete documentation index at: https://guide-fin.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # .Net .Net(core) 형식의 액션을 생성하고 다양하게 활용하는 방법과 예제를 소개합니다. 참고 - .Net Core 프로젝트를 컴파일, 테스트 및 압축하기 위해서는 [.Net Core SDK](https://dotnet.microsoft.com/download)를 로컬에 설치하고 환경변수 `DOTNET_HOME`을 `dotnet` 실행 파일이 있는 위치로 설정해야 합니다. ## 액션 생성 액션을 생성하려면 우선 .Net 액션 구조에 대해 이해해야 합니다. .Net Core 액션은 다음과 같은 .Net Core 라이브러리와 Main 함수의 구조로 되어 있습니다. ``` public Newtonsoft.Json.Linq.JObject Main(Newtonsoft.Json.Linq.JObject); ``` 액션 생성 예제를 확인하기 위해 `NCP.CloudFunctions.Example.Dotnet` 라는 C# 프로젝트를 생성해 주십시오. ``` dotnet new classlib -n NCP.CloudFunctions.Example.Dotnet -lang "C#" -f netstandard2.0 cd NCP.CloudFunctions.Example.Dotnet ``` 그런 다음 json 사용을 위해 [Newtonsoft.Json](https://www.newtonsoft.com/json), [NuGet](https://docs.microsoft.com/ko-kr/nuget/what-is-nuget) 패키지를 설치해 주십시오. ``` dotnet add package Newtonsoft.Json -v 12.0.1 ``` 이제 액션을 생성하는 예제를 확인해 보면 다음과 같습니다. 1. 액션 코드 `Hello.cs`를 작성해 주십시오. ``` using System; using Newtonsoft.Json.Linq; namespace NCP.CloudFunctions.Example.Dotnet { public class Hello { public JObject Main(JObject args) { string name = "stranger"; if (args.ContainsKey("name")) { name = args["name"].ToString(); } JObject message = new JObject(); message.Add("greeting", new JValue($"Hello, {name}!")); return (message); } } } ``` 2. 프로젝트 내용을 발행하기 위해 명령어를 실행해 주십시오. ``` dotnet publish -c Release -o out ``` 3. 명령어를 실행하여 발행된 내용을 zip 파일로 생성해 주십시오. ``` cd out zip -r -0 helloDotNet.zip * ``` 4. 생성한 zip 파일을 업로드하여 액션을 생성해 주십시오. ![cloudfunctions-exmaple-net_v2_01_ko](https://cdn.document360.io/0406ed95-101f-4cde-8dd8-308d03444a94/Images/Documentation/cloudfunctions-example-net_v2_01_ko.png) - .Net 형식으로 액션 생성 시 `Main` 함수는 `{Assembly}::{Class Full Name}::{Method}`의 형태로 작성해야 하기 때문에 위 예제의 경우 다음과 같은 형태로 Main 함수를 입력하여야 합니다. ``` NCP.CloudFunctions.Example.Dotnet::NCP.CloudFunctions.Example.Dotnet.Hello::Main ``` ![cloudfunctions-example-run-dotnet_mainFunc_ko](https://cdn.document360.io/0406ed95-101f-4cde-8dd8-308d03444a94/Images/Documentation/cloudfunctions-example-run-dotnet_mainFunc_ko.png)