---
title: ".Net"
slug: "cloudfunctions-example-net"
tags: [".net"]
updated: 2026-05-21T09:01:35Z
published: 2026-05-21T09:03:11Z
canonical: "guide-gov.ncloud-docs.com/cloudfunctions-example-net"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://guide-gov.ncloud-docs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# .Net

<p class="platform-info type-classic-vpc">Classic/VPC 환경에서 이용 가능합니다.</p>

.Net(core) 형식의 액션을 생성하고 다양하게 활용하는 방법과 예제를 소개합니다.

:::(Info) (참고)
.Net Core 프로젝트를 컴파일, 테스트 및 압축하기 위해서는 [.Net Core SDK](https://dotnet.microsoft.com/download){target="_blank"}를 로컬에 설치하고 환경변수 `DOTNET_HOME`을 `dotnet` 실행 파일이 있는 위치로 설정해야 합니다.
:::

## 액션 생성<a name="액션생성"></a>

액션을 생성하려면 우선 .Net 액션 구조에 대해 이해해야 합니다. .Net Core 액션은 다음과 같은 .Net Core 라이브러리와 Main 함수의 구조로 되어 있습니다.

```c#
public Newtonsoft.Json.Linq.JObject Main(Newtonsoft.Json.Linq.JObject);
```

액션 생성 예제를 확인하기 위해 `NCP.CloudFunctions.Example.Dotnet` 라는 C# 프로젝트를 생성해 주십시오.

```shell
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){target="_blank"}, [NuGet](https://docs.microsoft.com/ko-kr/nuget/what-is-nuget){target="_blank"} 패키지를 설치해 주십시오.

```shell
dotnet add package Newtonsoft.Json -v 12.0.1
```

이제 액션을 생성하는 예제를 확인해 보면 다음과 같습니다.

1. 액션 코드 `Hello.cs`를 작성해 주십시오.
    ```c#
    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. 프로젝트 내용을 발행하기 위해 명령어를 실행해 주십시오.

    ```shell
    dotnet publish -c Release -o out
    ```

3. 명령어를 실행하여 발행된 내용을 zip 파일로 생성해 주십시오.

    ```shell
    cd out
    zip -r -0 helloDotNet.zip *
    ```
4. 생성한 zip 파일을 업로드하여 액션을 생성해 주십시오.
![cloudfunctions-example-net_v2_01_ko.png](https://cdn.document360.io/f2d93c92-8957-408f-94df-b9b370f76a32/Images/Documentation/cloudfunctions-example-net_v2_01_ko.png){height="" width="70%"}

    * .Net 형식으로 액션 생성 시 `Main` 함수는 `{Assembly}::{Class Full Name}::{Method}`의 형태로 작성해야 하기 때문에 위 예제의 경우 다음과 같은 형태로 Main 함수를 입력하여야 합니다.
        ``` c#   
        NCP.CloudFunctions.Example.Dotnet::NCP.CloudFunctions.Example.Dotnet.Hello::Main
        ```
        ![cloudfunctions-example-run-dotnet_mainFunc_ko](https://cdn.document360.io/f2d93c92-8957-408f-94df-b9b370f76a32/Images/Documentation/cloudfunctions-example-run-dotnet_mainFunc_ko.png){height="" width="70%"}
