

버전 4(V4) AWS SDK for .NET 가 릴리스되었습니다.

변경 사항 해제 및 애플리케이션 마이그레이션에 대한 자세한 내용은 [마이그레이션 주제를](https://docs.aws.amazon.com/sdk-for-net/v4/developer-guide/net-dg-v4.html) 참조하세요.

 [https://docs.aws.amazon.com/sdk-for-net/v4/developer-guide/net-dg-v4.html](https://docs.aws.amazon.com/sdk-for-net/v4/developer-guide/net-dg-v4.html)

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 시작하기 AWS SDK for .NET
시작

를 설치, 설정 및 사용하는 방법을 알아봅니다 AWS SDK for .NET. 도구 체인을 설치하고 애플리케이션이 AWS 서비스에 액세스하는 데 필요한 여러 가지 필수 항목을 설정해야 합니다. 다음이 포함됩니다.
+ 적절한 사용자 계정 또는 역할
+ 해당 사용자 계정 또는 해당 역할을 수임하기 위한 인증 정보

프로젝트 및 기타 중요한 부분을 구성하는 방법에 대한 자세한 내용은 섹션을 참조하세요[구성 AWS SDK for .NET](configuring-the-sdk.md).

**Topics**
+ [도구 체인 설치 및 구성](net-dg-dev-env.md)
+ [를 사용하여 인증 AWS](creds-idc.md)
+ [간단한 애플리케이션 생성](quick-start.md)

# 용 도구 체인 설치 및 구성 AWS SDK for .NET
도구 체인 설치 및 구성

를 사용하려면 특정 개발 도구가 설치되어 있어야 AWS SDK for .NET합니다.

## 교차 플랫폼 개발


Windows, Linux 또는 macOS에서 교차 플랫폼 .NET 개발에 대한 필수 항목은 다음과 같습니다.
+ Microsoft [.NET Core SDK](https://learn.microsoft.com/en-us/dotnet/fundamentals/), 버전 2.1, 3.1 이상. 여기에는 .NET 명령줄 인터페이스(CLI)(**`dotnet`**) 및 .NET Core 런타임이 포함되어 있습니다.
+ 운영 체제 및 요구 사항에 적합한 코드 편집기 또는 통합 개발 환경(IDE)입니다. 이는 일반적으로 .NET Core에 대한 지원을 제공합니다.

  예를 들면 [Microsoft Visual Studio Code(VS Code)](https://code.visualstudio.com/), [JetBrains Rider](https://www.jetbrains.com/rider/), [Microsoft Visual Studio](https://visualstudio.microsoft.com/vs/) 등이 있습니다.
+ (선택 사항) 선택한 편집기와 운영 체제에 사용 가능한 AWS 도구 키트입니다.

  예를 들면 [AWS Toolkit for Visual Studio Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html), [AWS Toolkit for JetBrains](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) 및 [AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html)입니다.

## Visual Studio 및 .NET Core를 통한 Windows


Visual Studio 및 .NET Core를 통한 Windows 개발에 필요한 항목은 다음과 같습니다.
+ [Microsoft Visual Studio](https://visualstudio.microsoft.com/vs/)
+ Microsoft .NET Core 2.1, 3.1 이상

  일반적으로 Visual Studio의 최신 버전을 설치할 때 기본적으로 포함됩니다.
+ (선택 사항) Visual Studio에서 AWS 리소스 및 로컬 프로파일을 관리하기 위한 사용자 인터페이스를 제공하는 플러그인 AWS Toolkit for Visual Studio인 입니다. 툴킷을 설치하려면 [AWS Toolkit for Visual Studio설정](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/getting-set-up.html)을 참조하세요.

  자세한 내용은 [AWS Toolkit for Visual Studio 사용 설명서](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/)를 참조하십시오.

## 다음 단계


[를 AWS SDK for .NET 사용하여 인증 AWS](creds-idc.md)

# 를 AWS SDK for .NET 사용하여 인증 AWS
를 사용하여 인증 AWS

로 개발할 AWS 때 로 코드를 인증하는 방법을 설정해야 합니다 AWS 서비스. 환경 및 사용 가능한 액세스에 따라 AWS 리소스에 대한 프로그래밍 방식 AWS 액세스를 구성할 수 있는 다양한 방법이 있습니다.

SDK에 대한 다양한 인증 방법을 확인하려면 *AWS SDK 및 도구 참조 가이드*에서 [인증 및 액세스](https://docs.aws.amazon.com/sdkref/latest/guide/access.html)를 참조하세요.

이 주제에서는 새 사용자가 로컬에서 개발 중이고, 고용주로부터 인증 방법을 받지 않았으며, AWS IAM Identity Center 를 사용하여 임시 자격 증명을 얻을 것이라고 가정합니다. 사용자 환경이 이러한 가정에 해당하지 않는 경우 이 주제의 일부 정보가 사용자에게 적용되지 않거나 일부 정보가 이미 제공되었을 수 있습니다.

 이 환경을 구성하려면 몇 가지 단계를 수행해야 하며, 요약하면 다음과 같습니다.

1. [콘솔 자격 증명을 사용하여 로그인](#login-con-creds)

1. [IAM Identity Center 사용 및 구성](#idc-config-sso)

1. [IAM Identity Center를 사용하도록 SDK를 구성합니다.](#idc-config-sdk)

1. [AWS 액세스 포털 세션 시작](#idc-start-portal)

## 콘솔 자격 증명을 사용하여 로그인


기존 AWS Management Console 로그인 자격 증명을 사용하여 AWS 서비스에 프로그래밍 방식으로 액세스할 수 있습니다. 브라우저 기반 인증 흐름 후는 AWS CLI AWS Tools for PowerShell 및 .NET v4용 AWS SDK와 같은 로컬 개발 도구에서 작동하는 임시 자격 증명을 AWS 생성합니다.

이 프로세스를 사용하면 초기 계정 설정 중에 생성된 루트 자격 증명, IAM 사용자 또는 자격 증명 공급자의 페더레이션 자격 증명을 사용하여 인증할 수 있으며 AWS CLI 또는 AWS Tools for PowerShell 가 자동으로 임시 자격 증명을 관리합니다. 이 접근 방식은 장기 자격 증명을 로컬에 저장할 필요가 없으므로 보안이 강화됩니다. 에서 `Invoke-AWSLogin ` AWS Tools for PowerShell cmdlet을 실행하거나 AWS CLI에서 `aws login` 명령을 실행하면 활성 콘솔 세션에서 선택하거나 브라우저 기반 인증 흐름을 통해 로그인할 수 있으며, 그러면 임시 자격 증명이 자동으로 생성됩니다. 임시 자격 증명 토큰은 15분 후에 만료되지만 .NET v4용 AWS SDK는 요청 중에 필요한 경우 토큰을 자동으로 새로 고칩니다.

**중요**  
인증에 콘솔 자격 증명을 사용하는 경우 애플리케이션이 다음 NuGet 패키지를 참조해야 AWS 로그인 확인이 작동합니다.  
**AWSSDK.Signin**
이러한 패키지를 참조하지 않으면 런타임 예외가 발생합니다.
+ [AWS Tools for PowerShell 로그인 ID 개발자 안내서.](https://docs.aws.amazon.com/powershell/v5/userguide/creds-idc.html#login-con-creds)
+ [AWS CLI를 사용하여 콘솔 자격 증명을 사용하여 AWS 로컬 개발을 위해 로그인합니다.](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sign-in.html)

 AWS Tools for PowerShell 또는 AWS CLI에 대해 위에 제공된 단계를 따라 로그인하면 `config` 파일은 다음과 같습니다.

```
[default]
login_session = arn:aws:iam::0123456789012:user/username
region = us-east-1

[my-dev-profile]
login_session = arn:aws:iam::0123456789012:user/username
region = us-east-1
```

## IAM Identity Center 사용 및 구성


IAM Identity Center를 사용하려면 먼저 사용하도록 설정하고 구성해야 합니다. SDK에서 이 작업을 수행하는 방법에 대한 자세한 내용은 *AWS SDK 및 도구 참조 가이드*의 [IAM Identity Center 인증](https://docs.aws.amazon.com/sdkref/latest/guide/access-sso.html) 항목에 있는 **1단계**를 참조하세요. 특히 **IAM Identity Center를 통한 액세스가 설정되어 있지 않습니다** 아래에 있는 필요한 지침을 따르세요.

## IAM Identity Center를 사용하도록 SDK를 구성합니다.


IAM Identity Center를 사용하도록 SDK를 구성하는 방법에 대한 정보는 *AWS SDK 및 도구 참조 가이드*의 [IAM Identity Center 인증](https://docs.aws.amazon.com/sdkref/latest/guide/access-sso.html)에 대한 항목의 **2단계**에 나와 있습니다. 이 구성을 완료하면 시스템에 다음 요소가 포함되어야 합니다.
+ 애플리케이션을 실행하기 전에 AWS 액세스 포털 세션을 시작하는 데 AWS CLI사용하는 입니다.
+ SDK에서 참조할 수 있는 구성 값 세트가 있는 [`[default]` 프로파일](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html#file-format-profile)이 포함된 공유 AWS `config` 파일입니다. 이 파일의 위치를 찾으려면 **AWS SDK 및 도구 참조 가이드에서 [공유 파일의 위치](https://docs.aws.amazon.com/sdkref/latest/guide/file-location.html)를 참조하세요. 는 요청을 보내기 전에 프로필의 SSO 토큰 공급자를 AWS SDK for .NET 사용하여 자격 증명을 획득합니다 AWS. `sso_role_name` 값은 IAM 신원 센터 권한 집합에 연결된 IAM 역할로, 애플리케이션에서 사용되는 AWS 서비스 서비스에 대한 액세스를 허용해야 합니다.

  다음 샘플 `config` 파일은 SSO 토큰 공급자로 설정된 기본 프로필을 보여줍니다. 프로필의 `sso_session` 설정은 이름이 지정된 `sso-session` 섹션을 참조합니다. `sso-session` 섹션에는 AWS 액세스 포털 세션을 시작하는 설정이 포함되어 있습니다.

  ```
  [default]
  sso_session = my-sso
  sso_account_id = 111122223333
  sso_role_name = SampleRole
  region = us-east-1
  output = json
  
  [sso-session my-sso]
  sso_region = us-east-1
  sso_start_url = https://provided-domain.awsapps.com/start
  sso_registration_scopes = sso:account:access
  ```

**중요**  
인증 AWS IAM Identity Center 에를 사용하는 경우 SSO 확인이 작동하려면 애플리케이션이 다음 NuGet 패키지를 참조해야 합니다.  
`AWSSDK.SSO`
`AWSSDK.SSOOIDC`
이러한 패키지를 참조하지 않으면 *런타임* 예외가 발생합니다.

## AWS 액세스 포털 세션 시작


에 액세스하는 애플리케이션을 실행하기 전에 SDK가 IAM Identity Center 인증을 사용하여 자격 증명을 확인하려면 활성 AWS 액세스 포털 세션이 AWS 서비스필요합니다. 구성된 세션 길이에 따라 결국 액세스가 만료되고 SDK에 인증 오류가 발생합니다. AWS 액세스 포털에 로그인하려면에서 다음 명령을 실행합니다 AWS CLI.

```
aws sso login
```

기본 프로필이 설정되어 있으므로 `--profile` 옵션으로 명령을 호출할 필요가 없습니다. SSO 토큰 공급자 구성에서 명명된 프로필을 사용하는 경우 `aws sso login --profile named-profile` 명령을 사용합니다.

이미 활성 세션이 있는지 테스트하려면 다음 AWS CLI 명령을 실행합니다.

```
aws sts get-caller-identity
```

이 명령에 대한 응답은 공유 `config` 파일에 구성된 IAM Identity Center 계정 및 권한 집합을 보고해야 합니다.

**참고**  
이미 활성 AWS 액세스 포털 세션이 있고를 실행하는 경우 `aws sso login`자격 증명을 제공할 필요가 없습니다.  
로그인 프로세스에서 데이터에 대한 AWS CLI 액세스를 허용하라는 메시지가 표시될 수 있습니다. AWS CLI 는 SDK for Python을 기반으로 구축되므로 권한 메시지에 `botocore` 이름의 변형이 포함될 수 있습니다.

## 추가 정보

+ 개발 환경에서 IAM Identity Center 및 SSO를 사용하는 방법에 대한 추가 정보는 [고급 인증](advanced-auth.md)섹션의 [Single Sign-On](sso.md)를 참조하세요. 이 정보에는 대체 방법 및 고급 방법과 이러한 방법을 사용하는 방법을 보여주는 자습서가 포함되어 있습니다.
+ 프로필 및 환경 변수 사용과 같은 SDK 인증에 대한 자세한 옵션은 *AWS SDK 및 도구 참조 가이드*의 [구성](https://docs.aws.amazon.com/sdkref/latest/guide/creds-config-files.html) 장을 참조하세요.
+ 모범 사례에 대해 자세히 알아보려면 **IAM 사용 설명서에서 [IAM의 보안 모범 사례](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)를 참조하세요.
+ 단기 AWS 자격 증명을 생성하려면 *IAM 사용 설명서*의 [임시 보안 자격 증명을 참조하세요](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html).
+ 다른 보안 인증 공급자에 대해 알아보려면 **AWS SDK 및 도구 참조 가이드에서 [표준화된 보안 인증 공급자](https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html)를 참조하세요.

# 를 사용하여 간단한 애플리케이션 생성 AWS SDK for .NET
간단한 애플리케이션 생성

이 섹션은 AWS SDK for .NET에 익숙하지 않은 개발자를 위한 기본 자습서를 제공합니다.

**참고**  
이 자습서를 사용하기 전에 먼저 [도구 체인을 설치](net-dg-dev-env.md)하고 [SDK 인증을 구성](creds-idc.md)해야 합니다.

코드 예제와 함께 특정 AWS 서비스를 위한 소프트웨어 개발에 대한 자세한 내용은 섹션을 참조하세요[ AWS 서비스 호출](working-with-aws-services.md). 추가 코드 예제는 [SDK for .NET (v4) 코드 예제](csharp_code_examples.md) 단원을 참조하세요.

**Topics**
+ [간단한 교차 플랫폼 앱](quick-start-s3-1-cross.md)
+ [간단한 Windows 기반 앱](quick-start-s3-1-winvs.md)
+ [

# 다음 단계
](quick-start-next-steps.md)

# 를 사용하는 간단한 교차 플랫폼 애플리케이션 AWS SDK for .NET
간단한 교차 플랫폼 앱

이 자습서에서는 교차 플랫폼 개발을 위해 AWS SDK for .NET 및 .NET Core를 사용합니다. 이 자습서는 SDK를 사용하여 소유한 [Amazon S3 버킷](https://docs.aws.amazon.com/AmazonS3/latest/userguide/)을 나열하고 선택적으로 버킷을 생성하는 방법을 보여줍니다.

.NET 명령줄 인터페이스(CLI)와 같은 교차 플랫폼 도구를 사용하여 이 자습서를 수행합니다. 개발 환경을 구성하는 다른 방법은 [용 도구 체인 설치 및 구성 AWS SDK for .NET](net-dg-dev-env.md)을 참조하십시오.

**Windows, Linux 또는 macOS에서 교차 플랫폼 .NET 개발에 대한 필수 항목:**
+ Microsoft [.NET Core SDK](https://learn.microsoft.com/en-us/dotnet/fundamentals/), 버전 2.1, 3.1 이상. 여기에는 .NET 명령줄 인터페이스(CLI)(**`dotnet`**) 및 .NET Core 런타임이 포함되어 있습니다.
+ 운영 체제 및 요구 사항에 적합한 코드 편집기 또는 통합 개발 환경(IDE)입니다. 이는 일반적으로 .NET Core에 대한 지원을 제공합니다.

  예를 들면 [Microsoft Visual Studio Code(VS Code)](https://code.visualstudio.com/), [JetBrains Rider](https://www.jetbrains.com/rider/), [Microsoft Visual Studio](https://visualstudio.microsoft.com/vs/) 등이 있습니다.

**참고**  
이 자습서를 사용하기 전에 먼저 [도구 체인을 설치](net-dg-dev-env.md)하고 [SDK 인증을 구성](creds-idc.md)해야 합니다.

## 단계

+ [프로젝트 생성](#s3-1-cross-create-project)
+ [코드 생성](#s3-1-cross-code)
+ [애플리케이션을 실행합니다](#s3-1-cross-run)
+ [정리](#s3-1-cross-clean-up)

## 프로젝트 생성


1. 명령 프롬프트 또는 터미널을 엽니다. .NET 프로젝트를 만들 수 있는 운영 체제 폴더를 찾거나 생성합니다.

1. 해당 폴더에서 다음 명령을 실행하여 .NET 프로젝트를 만듭니다.

   ```
   dotnet new console --name S3CreateAndList
   ```

1. 새로 만든 `S3CreateAndList` 폴더로 이동하여 다음 명령을 실행합니다.

   ```
   dotnet add package AWSSDK.S3
   dotnet add package AWSSDK.SecurityToken
   dotnet add package AWSSDK.SSO
   dotnet add package AWSSDK.SSOOIDC
   ```

   위의 명령은 [NuGet 패키지 관리자](https://www.nuget.org/profiles/awsdotnet)에서 NuGet 패키지를 설치합니다. 이 자습서에 필요한 NuGet 패키지를 정확하게 알고 있으므로 이제 이 단계를 수행할 수 있습니다. 또한 필요한 패키지가 개발 중에 알려지게 되는 것이 일반적입니다. 이 경우 비슷한 명령을 실행할 수 있습니다.

## 코드 생성


1. `S3CreateAndList` 폴더에서 `Program.cs`를 찾아 코드 편집기에서 엽니다.

1. 내용을 다음 코드로 바꾸고 파일을 저장합니다.

   ```
   using System;
   using System.Threading.Tasks;
   
   // NuGet packages: AWSSDK.S3, AWSSDK.SecurityToken, AWSSDK.SSO, AWSSDK.SSOOIDC
   using Amazon.Runtime;
   using Amazon.Runtime.CredentialManagement;
   using Amazon.S3;
   using Amazon.S3.Model;
   using Amazon.SecurityToken;
   using Amazon.SecurityToken.Model;
   
   namespace S3CreateAndList
   {
       class Program
       {
           // This code is part of the quick tour in the developer guide.
           // See https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/quick-start.html
           // for complete steps.
           // Requirements:
           // - An SSO profile in the SSO user's shared config file with sufficient privileges for
   		//   STS and S3 buckets.
           // - An active SSO Token.
           //    If an active SSO token isn't available, the SSO user should do the following:
           //    In a terminal, the SSO user must call "aws sso login".
   
           // Class members.
           static async Task Main(string[] args)
           {
               // Get SSO credentials from the information in the shared config file.
               // For this tutorial, the information is in the [default] profile.
               var ssoCreds = LoadSsoCredentials("default");
   
               // Display the caller's identity.
               var ssoProfileClient = new AmazonSecurityTokenServiceClient(ssoCreds);
               Console.WriteLine($"\nSSO Profile:\n {await ssoProfileClient.GetCallerIdentityArn()}");
   
               // Create the S3 client is by using the SSO credentials obtained earlier.
               var s3Client = new AmazonS3Client(ssoCreds);
   
               // Parse the command line arguments for the bucket name.
               if (GetBucketName(args, out String bucketName))
               {
                   // If a bucket name was supplied, create the bucket.
                   // Call the API method directly
                   try
                   {
                       Console.WriteLine($"\nCreating bucket {bucketName}...");
                       var createResponse = await s3Client.PutBucketAsync(bucketName);
                       Console.WriteLine($"Result: {createResponse.HttpStatusCode.ToString()}");
                   }
                   catch (Exception e)
                   {
                       Console.WriteLine("Caught exception when creating a bucket:");
                       Console.WriteLine(e.Message);
                   }
               }
   
               // Display a list of the account's S3 buckets.
               Console.WriteLine("\nGetting a list of your buckets...");
               var listResponse = await s3Client.ListBucketsAsync();
               Console.WriteLine($"Number of buckets: {listResponse.Buckets.Count}");
               foreach (S3Bucket b in listResponse.Buckets)
               {
                   Console.WriteLine(b.BucketName);
               }
               Console.WriteLine();
           }
   
           // 
           // Method to parse the command line.
           private static Boolean GetBucketName(string[] args, out String bucketName)
           {
               Boolean retval = false;
               bucketName = String.Empty;
               if (args.Length == 0)
               {
                   Console.WriteLine("\nNo arguments specified. Will simply list your Amazon S3 buckets." +
                     "\nIf you wish to create a bucket, supply a valid, globally unique bucket name.");
                   bucketName = String.Empty;
                   retval = false;
               }
               else if (args.Length == 1)
               {
                   bucketName = args[0];
                   retval = true;
               }
               else
               {
                   Console.WriteLine("\nToo many arguments specified." +
                     "\n\ndotnet_tutorials - A utility to list your Amazon S3 buckets and optionally create a new one." +
                     "\n\nUsage: S3CreateAndList [bucket_name]" +
                     "\n - bucket_name: A valid, globally unique bucket name." +
                     "\n - If bucket_name isn't supplied, this utility simply lists your buckets.");
                   Environment.Exit(1);
               }
               return retval;
           }
   
           //
           // Method to get SSO credentials from the information in the shared config file.
           static AWSCredentials LoadSsoCredentials(string profile)
           {
               var chain = new CredentialProfileStoreChain();
               if (!chain.TryGetAWSCredentials(profile, out var credentials))
                   throw new Exception($"Failed to find the {profile} profile");
               return credentials;
           }
       }
   
       // Class to read the caller's identity.
       public static class Extensions
       {
           public static async Task<string> GetCallerIdentityArn(this IAmazonSecurityTokenService stsClient)
           {
               var response = await stsClient.GetCallerIdentityAsync(new GetCallerIdentityRequest());
               return response.Arn;
           }
       }
   }
   ```

## 애플리케이션을 실행합니다


1. 다음 명령을 실행합니다.

   ```
   dotnet run
   ```

1. 출력을 검사하여 소유한 Amazon S3 버킷 수(있는 경우)와 해당 이름을 확인합니다.

1. 새 Amazon S3 버킷의 이름을 선택합니다. "dotnet-quicktour-s3-1-cross-"를 기본으로 사용하고 GUID 또는 사용자 이름과 같은 고유한 항목을 추가합니다. [Amazon S3 사용 설명서](https://docs.aws.amazon.com/AmazonS3/latest/userguide/)의 [버킷 이름 지정 규칙](https://docs.aws.amazon.com/AmazonS3/latest/userguide/BucketRestrictions.html#bucketnamingrules)에 설명된 대로 버킷 이름 규칙을 준수해야 합니다.

1. 다음 명령을 실행하여 *amzn-s3-demo-bucket*을 선택한 버킷의 이름으로 바꿉니다.

   ```
   dotnet run amzn-s3-demo-bucket
   ```

1. 출력을 검사하여 생성된 새 버킷을 확인합니다.

## 정리


이 자습서를 수행하는 동안 현재 정리하도록 선택할 수 있는 몇 가지 리소스를 만들었습니다.
+ 이전 단계에서 애플리케이션이 생성한 버킷을 유지하지 않으려면 [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/)에서 Amazon S3 콘솔을 사용하여 삭제합니다.
+ .NET 프로젝트를 유지하지 않으려면 개발 환경에서 `S3CreateAndList` 폴더를 제거하십시오.

## 다음으로 진행할 단계


[간략한 설명 메뉴](quick-start.md)로 이동하거나 이 [간략한 설명의 끝](quick-start-next-steps.md)으로 바로 이동합니다.

# 를 사용하는 간단한 Windows 기반 애플리케이션 AWS SDK for .NET
간단한 Windows 기반 앱

이 자습서에서는 Windows AWS SDK for .NET 에서 Visual Studio 및 .NET Core와 함께를 사용합니다. 이 자습서는 SDK를 사용하여 소유한 [Amazon S3 버킷](https://docs.aws.amazon.com/AmazonS3/latest/userguide/)을 나열하고 선택적으로 버킷을 생성하는 방법을 보여줍니다.

Visual Studio 및 .NET Core를 사용하여 Windows에서 이 자습서를 수행하게 됩니다. 개발 환경을 구성하는 다른 방법은 [용 도구 체인 설치 및 구성 AWS SDK for .NET](net-dg-dev-env.md)을 참조하십시오.

**Visual Studio 및 .NET Core를 통한 Windows 개발에 필요한 항목:**
+ [Microsoft Visual Studio](https://visualstudio.microsoft.com/vs/)
+ Microsoft .NET Core 2.1, 3.1 이상

  일반적으로 Visual Studio의 최신 버전을 설치할 때 기본적으로 포함됩니다.

**참고**  
이 자습서를 사용하기 전에 먼저 [도구 체인을 설치](net-dg-dev-env.md)하고 [SDK 인증을 구성](creds-idc.md)해야 합니다.

## 단계

+ [프로젝트 생성](#s3-1-winvs-create-project)
+ [코드 생성](#s3-1-winvs-code)
+ [애플리케이션을 실행합니다](#s3-1-winvs-run)
+ [정리](#s3-1-winvs-clean-up)

## 프로젝트 생성


1. Visual Studio를 열고 **콘솔 앱** 템플릿의 C\$1 버전을 사용하는 새 프로젝트를 생성합니다. 즉, "....NET에서 실행할 수 있는 명령줄 애플리케이션 생성의 경우..."라는 설명이 있습니다. `S3CreateAndList` 프로젝트의 이름을 지정합니다.
**참고**  
콘솔 앱 템플릿의 .NET Framework 버전을 선택하지 마십시오. 선택했다면 .NET Framework 4.7.2 이상을 사용해야 합니다.

1. 새로 생성된 프로젝트를 로드한 상태에서 **도구**, **NuGet Package Manager(NuGet 패키지 관리자)**, **Manage NuGet Packages for Solution(솔루션을 위한 NuGet 패키지 관리)**을 선택합니다.

1. `AWSSDK.S3`, `AWSSDK.SecurityToken`, `AWSSDK.SSO` 및 `AWSSDK.SSOOIDC`의 NuGet 패키지를 찾아 프로젝트에 설치합니다.

   이 프로세스는 [NuGet 패키지 관리자](https://www.nuget.org/profiles/awsdotnet)에서 NuGet 패키지를 설치합니다. 이 자습서에 필요한 NuGet 패키지를 정확하게 알고 있으므로 이제 이 단계를 수행할 수 있습니다. 또한 필요한 패키지가 개발 중에 알려지게 되는 것이 일반적입니다. 이 경우 유사한 프로세스를 따라 설치하십시오.

1. 명령 프롬프트에서 애플리케이션을 실행하려는 경우 이제 명령 프롬프트를 열고 빌드 출력이 포함될 폴더로 이동합니다. 일반적으로 `S3CreateAndList\S3CreateAndList\bin\Debug\net6.0`과 비슷하지만, 환경에 따라 달라집니다.

## 코드 생성


1. `S3CreateAndList` 프로젝트에서 `Program.cs`를 찾아 IDE에서 엽니다.

1. 내용을 다음 코드로 바꾸고 파일을 저장합니다.

   ```
   using System;
   using System.Threading.Tasks;
   
   // NuGet packages: AWSSDK.S3, AWSSDK.SecurityToken, AWSSDK.SSO, AWSSDK.SSOOIDC
   using Amazon.Runtime;
   using Amazon.Runtime.CredentialManagement;
   using Amazon.S3;
   using Amazon.S3.Model;
   using Amazon.SecurityToken;
   using Amazon.SecurityToken.Model;
   
   namespace S3CreateAndList
   {
       class Program
       {
           // This code is part of the quick tour in the developer guide.
           // See https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/quick-start.html
           // for complete steps.
           // Requirements:
           // - An SSO profile in the SSO user's shared config file with sufficient privileges for
   		//   STS and S3 buckets.
           // - An active SSO Token.
           //    If an active SSO token isn't available, the SSO user should do the following:
           //    In a terminal, the SSO user must call "aws sso login".
   
           // Class members.
           static async Task Main(string[] args)
           {
               // Get SSO credentials from the information in the shared config file.
               // For this tutorial, the information is in the [default] profile.
               var ssoCreds = LoadSsoCredentials("default");
   
               // Display the caller's identity.
               var ssoProfileClient = new AmazonSecurityTokenServiceClient(ssoCreds);
               Console.WriteLine($"\nSSO Profile:\n {await ssoProfileClient.GetCallerIdentityArn()}");
   
               // Create the S3 client is by using the SSO credentials obtained earlier.
               var s3Client = new AmazonS3Client(ssoCreds);
   
               // Parse the command line arguments for the bucket name.
               if (GetBucketName(args, out String bucketName))
               {
                   // If a bucket name was supplied, create the bucket.
                   // Call the API method directly
                   try
                   {
                       Console.WriteLine($"\nCreating bucket {bucketName}...");
                       var createResponse = await s3Client.PutBucketAsync(bucketName);
                       Console.WriteLine($"Result: {createResponse.HttpStatusCode.ToString()}");
                   }
                   catch (Exception e)
                   {
                       Console.WriteLine("Caught exception when creating a bucket:");
                       Console.WriteLine(e.Message);
                   }
               }
   
               // Display a list of the account's S3 buckets.
               Console.WriteLine("\nGetting a list of your buckets...");
               var listResponse = await s3Client.ListBucketsAsync();
               Console.WriteLine($"Number of buckets: {listResponse.Buckets.Count}");
               foreach (S3Bucket b in listResponse.Buckets)
               {
                   Console.WriteLine(b.BucketName);
               }
               Console.WriteLine();
           }
   
           // 
           // Method to parse the command line.
           private static Boolean GetBucketName(string[] args, out String bucketName)
           {
               Boolean retval = false;
               bucketName = String.Empty;
               if (args.Length == 0)
               {
                   Console.WriteLine("\nNo arguments specified. Will simply list your Amazon S3 buckets." +
                     "\nIf you wish to create a bucket, supply a valid, globally unique bucket name.");
                   bucketName = String.Empty;
                   retval = false;
               }
               else if (args.Length == 1)
               {
                   bucketName = args[0];
                   retval = true;
               }
               else
               {
                   Console.WriteLine("\nToo many arguments specified." +
                     "\n\ndotnet_tutorials - A utility to list your Amazon S3 buckets and optionally create a new one." +
                     "\n\nUsage: S3CreateAndList [bucket_name]" +
                     "\n - bucket_name: A valid, globally unique bucket name." +
                     "\n - If bucket_name isn't supplied, this utility simply lists your buckets.");
                   Environment.Exit(1);
               }
               return retval;
           }
   
           //
           // Method to get SSO credentials from the information in the shared config file.
           static AWSCredentials LoadSsoCredentials(string profile)
           {
               var chain = new CredentialProfileStoreChain();
               if (!chain.TryGetAWSCredentials(profile, out var credentials))
                   throw new Exception($"Failed to find the {profile} profile");
               return credentials;
           }
       }
   
       // Class to read the caller's identity.
       public static class Extensions
       {
           public static async Task<string> GetCallerIdentityArn(this IAmazonSecurityTokenService stsClient)
           {
               var response = await stsClient.GetCallerIdentityAsync(new GetCallerIdentityRequest());
               return response.Arn;
           }
       }
   }
   ```

1. 애플리케이션을 빌드합니다.
**참고**  
이전 버전의 Visual Studio를 사용하는 경우 다음과 유사한 빌드 오류가 발생할 수 있습니다.  
“C\$1 7.0에서는 '비동기 메인' 기능을 사용할 수 없습니다. 언어 버전 7.1 이상을 사용하십시오.”  
이 오류가 발생하면 해당 언어의 최신 버전을 사용하도록 프로젝트를 설정하세요. 이 작업은 일반적으로 프로젝트 속성, **빌드**, **고급**에서 수행됩니다.

## 애플리케이션을 실행합니다


1. 명령줄 인수 없이 애플리케이션을 실행합니다. 명령 프롬프트(이전에 연 경우) 또는 IDE에서 이 작업을 수행합니다.

1. 출력을 검사하여 소유한 Amazon S3 버킷 수(있는 경우)와 해당 이름을 확인합니다.

1. 새 Amazon S3 버킷의 이름을 선택합니다. "dotnet-quicktour-s3-1-winvs-"를 기본으로 사용하고 GUID 또는 사용자 이름과 같은 고유한 항목을 추가합니다. [Amazon S3 사용 설명서](https://docs.aws.amazon.com/AmazonS3/latest/userguide/)의 [버킷 이름 지정 규칙](https://docs.aws.amazon.com/AmazonS3/latest/userguide/BucketRestrictions.html#bucketnamingrules)에 설명된 대로 버킷 이름 규칙을 준수해야 합니다.

1. 애플리케이션을 다시 실행합니다. 이번에는 버킷 이름을 제공합니다.

   명령줄에서 다음 명령의 *amzn-s3-demo-bucket*을 선택한 버킷의 이름으로 바꿉니다.

   ```
   S3CreateAndList amzn-s3-demo-bucket
   ```

   또는 IDE에서 애플리케이션을 실행하는 경우 **프로젝트**, **S3CreateAndList Properties(S3CreateAndList 속성)**, **디버깅**으로 선택하고 버킷 이름을 입력합니다.

1. 출력을 검사하여 생성된 새 버킷을 확인합니다.

## 정리


이 자습서를 수행하는 동안 현재 정리하도록 선택할 수 있는 몇 가지 리소스를 만들었습니다.
+ 이전 단계에서 애플리케이션이 생성한 버킷을 유지하지 않으려면 [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/)에서 Amazon S3 콘솔을 사용하여 삭제합니다.
+ .NET 프로젝트를 유지하지 않으려면 개발 환경에서 `S3CreateAndList` 폴더를 제거하십시오.

## 다음으로 진행할 단계


[간략한 설명 메뉴](quick-start.md)로 이동하거나 이 [간략한 설명의 끝](quick-start-next-steps.md)으로 바로 이동합니다.

# 다음 단계


이 자습서를 수행하는 동안 생성한 리소스 중 남은 리소스를 모두 정리해야 합니다. 이러한 AWS 리소스는 파일 및 폴더와 같은 개발 환경의 리소스일 수 있습니다.

이제를 둘러보았으므로 프로젝트를 시작할 AWS SDK for .NET수 있습니다. [새 프로젝트 시작](net-dg-start-new-project.md) 