빠른 시작: .NET용 Azure SDK를 사용하여 Azure 관리 CCF 리소스 만들기

Azure 관리 CCF(관리 CCF)는 기밀 애플리케이션을 배포하기 위한 새롭고 매우 안전한 서비스입니다. 관리 CCF 및 예제 사용 사례에 대한 자세한 내용은 Azure Managed Confidential Consortium Framework 정보를 참조 하세요.

이 빠른 시작에서는 .NET 클라이언트 관리 라이브러리를 사용하여 관리 CCF 리소스를 만드는 방법을 알아봅니다.

Azure를 구독하고 있지 않다면 시작하기 전에 Azure 체험 계정을 만듭니다.

API 참조 설명서 | 라이브러리 소스 코드 | 패키지(NuGet)

필수 조건

설정

새 .NET 콘솔 앱 만들기

  1. 명령 셸에서 다음 명령을 실행하여 managedccf-app이라는 이름의 프로젝트를 만듭니다.

    dotnet new console --name managedccf-app
    
  2. 새로 만든 managedccf-app 디렉터리로 변경하고, 다음 명령을 실행하여 프로젝트를 빌드합니다.

    dotnet build
    

    빌드 출력에 경고나 오류가 포함되지 않아야 합니다.

    Build succeeded.
     0 Warning(s)
     0 Error(s)
    

패키지 설치

NuGet을 사용하여 .NET용 Azure 관리 CCF 클라이언트 라이브러리를 설치합니다.

dotnet add package Azure.ResourceManager.ConfidentialLedger --version 1.1.0-beta.2

이 빠른 시작에서는 Azure ID용 Azure SDK 클라이언트 라이브러리도 설치해야 합니다.

dotnet add package Azure.Identity

리소스 그룹 만들기

리소스 그룹은 Azure 리소스가 배포 및 관리되는 논리적 컨테이너입니다. Azure PowerShell New-AzResourceGroup cmdlet을 사용하여 myResourceGroup 리소스 그룹을 southcentralus 위치에 만듭니다.

New-AzResourceGroup -Name "myResourceGroup" -Location "SouthCentralUS"

리소스 공급자 등록

리소스를 만들기 전에 Azure 관리 CCF 리소스 유형을 구독에 등록해야 합니다.

az feature registration create --namespace Microsoft.ConfidentialLedger --name ManagedCCF

az provider register --namespace Microsoft.ConfidentialLedger

멤버 만들기

멤버에 대한 키 쌍을 생성합니다. 다음 명령이 완료되면 멤버의 공개 키가 member0_cert.pem에 저장되고 프라이빗 키가 member0_privk.pem에 저장됩니다.

openssl ecparam -out "member0_privk.pem" -name "secp384r1" -genkey
openssl req -new -key "member0_privk.pem" -x509 -nodes -days 365 -out "member0_cert.pem" -"sha384" -subj=/CN="member0"

.NET 애플리케이션 만들기

관리 평면 클라이언트 라이브러리 사용

.NET용 Azure SDK(azure/arm-confidentialledger)를 사용하면 만들기 및 삭제, 구독과 연결된 리소스 나열 및 특정 리소스의 세부 정보 보기와 같은 관리 CCF 리소스에 대한 작업을 수행할 수 있습니다. 다음 코드 조각에서는 관리 CCF 리소스의 속성을 만들고 확인합니다.

다음 지시문을 Program.cs의 위쪽에 추가합니다.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.ConfidentialLedger;
using Azure.ResourceManager.ConfidentialLedger.Models;
using Azure.ResourceManager.Resources;

클라이언트 인증 및 만들기

이 빠른 시작에서는 로그인한 사용자를 사용하여 로컬 개발을 위한 기본 방법인 Azure 관리 CCF에 인증합니다. 이 예제에서는 ID를 제공하는 다양한 옵션이 있는 서로 다른 환경에서 동일한 코드를 사용할 수 있도록 하는 Azure Identity Library에서 'DefaultAzureCredential()' 클래스를 사용합니다.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://video2.skills-academy.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();

Azure Resource Manager 클라이언트를 만들고 토큰 자격 증명을 사용하여 인증합니다.

// authenticate your client
ArmClient client = new ArmClient(cred);

관리 CCF 리소스 만들기

// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "0000000-0000-0000-0000-000000000001";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);

// get the collection of this ManagedCcfResource
ManagedCcfCollection collection = resourceGroupResource.GetManagedCcfs();

// invoke the operation
string appName = "confidentialbillingapp";
ManagedCcfData data = new ManagedCcfData(new AzureLocation("SouthCentralUS"))
{
    Properties = new ManagedCcfProperties()
    {
        MemberIdentityCertificates =
        {
            new ConfidentialLedgerMemberIdentityCertificate()
            {
                Certificate = "-----BEGIN CERTIFICATE-----MIIBsjCCATigA...LjYAGDSGi7NJnSkA-----END CERTIFICATE-----",
                Encryptionkey = "",
                Tags = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
                {
                    ["additionalProps1"] = "additional properties"
                }),
            }
        },
        DeploymentType = new ConfidentialLedgerDeploymentType()
        {
            LanguageRuntime = ConfidentialLedgerLanguageRuntime.JS,
            AppSourceUri = new Uri(""),
        },
        NodeCount = 3,
    },
    Tags =
    {
        ["additionalProps1"] = "additional properties",
    },
};

ArmOperation<ManagedCcfResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appName, data);
ManagedCcfResource result = lro.Value;

// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedCcfData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");

관리 CCF 리소스의 속성 보기

다음 코드 조각은 관리 CCF 리소스를 검색하고 해당 속성을 출력합니다.

// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "0000000-0000-0000-0000-000000000001";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);

// get the collection of this ManagedCcfResource
ManagedCcfCollection collection = resourceGroupResource.GetManagedCcfs();

// invoke the operation
string appName = "confidentialbillingapp";
ManagedCcfResource result = await collection.GetAsync(appName);

// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedCcfData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");

리소스 그룹에 관리 CCF 리소스 나열

다음 코드 조각은 리소스 그룹에서 관리 CCF 리소스를 검색합니다.

// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "0000000-0000-0000-0000-000000000001";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);

// get the collection of this ManagedCcfResource
ManagedCcfCollection collection = resourceGroupResource.GetManagedCcfs();

// invoke the operation and iterate over the result
await foreach (ManagedCcfResource item in collection.GetAllAsync())
{
    // the variable item is a resource, you could call other operations on this instance as well
    // but just for demo, we get its data from this resource instance
    ManagedCcfData resourceData = item.Data;
    // for demo we just print out the id
    Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}

Console.WriteLine($"Succeeded");

구독에서 관리 CCF 리소스를 나열

다음 코드 조각은 구독에서 관리 CCF 리소스를 검색합니다.

// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "0000000-0000-0000-0000-000000000001";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);

// invoke the operation and iterate over the result
await foreach (ManagedCcfResource item in subscriptionResource.GetManagedCcfsAsync())
{
    // the variable item is a resource, you could call other operations on this instance as well
    // but just for demo, we get its data from this resource instance
    ManagedCcfData resourceData = item.Data;
    // for demo we just print out the id
    Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}

Console.WriteLine($"Succeeded");

리소스 정리

다른 관리 CCF 문서는 이 빠른 시작을 기반으로 빌드할 수 있습니다. 이후의 빠른 시작 및 자습서를 계속 진행하려는 경우 이러한 리소스를 유지하는 것이 좋습니다.

그렇지 않으면 이 문서에서 만든 리소스를 완료한 후 Azure CLI az group delete 명령을 사용하여 리소스 그룹과 포함된 모든 리소스를 삭제합니다.

az group delete --resource-group myResourceGroup

다음 단계

이 빠른 시작에서는 Confidential Ledger용 Azure Python SDK를 사용하여 관리 CCF 리소스를 만들었습니다. Azure 관리 CCF 및 애플리케이션과 통합하는 방법에 대해 자세히 알아보려면 다음 문서를 계속 진행하세요.