다음을 통해 공유


Azure 기밀 원장의 고급 사용자 정의 함수(미리 보기)

UDF(고급 사용자 정의 함수)를 사용하면 사용자 지정 코드를 원장과 동일한 TEE(신뢰할 수 있는 실행 환경)에서 실행할 수 있습니다. 이 기능은 기밀성 및 무결성 보장의 이점을 사용자 지정 코드로 확장합니다. 또한 권한 부여를 위해 사용자 지정 RBAC(역할 기반 액세스 제어)를 지원합니다.

중요합니다

사용자 정의 함수는 현재 API 버전 2024-08-22-preview에서 미리 보기로 제공됩니다. 이 등록 양식을 통해 이 미리 보기에 대한 액세스를 요청할 수 있습니다. 베타, 미리 보기로 제공되거나 아직 일반 공급으로 릴리스되지 않은 Azure 기능에 적용되는 약관은 Microsoft Azure 미리 보기에 대한 추가 사용 약관을 참조하세요.

팁 (조언)

간단한 사용자 지정 논리 또는 원장 API와의 직접 통합과 같은 간단한 시나리오는 Azure 기밀 원장의 간단한 사용자 정의 함수를 참조하세요.

사용 사례

고급 사용자 정의 함수가 도움이 될 수 있는 몇 가지 시나리오는 다음과 같습니다.

  • 데이터 분석 및 집계: 중요한 정보는 TEE에서 처리할 수 있으며 집계된 정보는 관련자와 공유할 수 있습니다.
  • 기밀 정보 보호: 개인 데이터, 신용 점수 및 건강 정보와 같은 기밀 정보는 증명 후 다른 기밀 워크로드와 공유할 수 있습니다.

필수 조건

이 자습서에서는 원장 인스턴스를 만들었다고 가정합니다. Azure Portal, Azure CLI 또는 Azure PowerShell을 사용하여 만들 수 있습니다.

애플리케이션 개발

원장 애플리케이션은 TypeScript를 사용하여 개발되고 JavaScript 번들로 롤업됩니다. 개발 프로세스에 대한 자세한 내용은 CCF(기밀 컨소시엄 프레임워크) 설명서를 참조 하세요.

중요합니다

관리자만 애플리케이션을 배포하고 블록체인 원장의 사용자 지정 RBAC를 관리할 수 있습니다. 섹션의 나머지 부분에서는 관리자가 명령을 실행한다고 가정합니다.

azureconfidentialledger-app-samples 리포지토리()에서 사용할 수 있는 뱅킹 애플리케이션을https://github.com/microsoft/azureconfidentialledger-app-samples 사용하여 기능을 보여 줍니다.

비고

은행 애플리케이션은 사용자 지정 역할 및 작업을 사용하여 계좌 개설, 예금 및 자금 이체와 같은 일반적으로 사용되는 은행 시나리오에 대한 API를 노출합니다.

Azure에 로그인

비고

Azure 기밀 원장은 Microsoft Entra ID를 기본적으로 지원합니다. 애플리케이션이 다른 ID 공급자와 통합되는 경우 고객 지원에 문의하여 원장에 구성합니다.

Microsoft Entra ID 토큰을 가져옵니다.

az login --use-device-code
az account get-access-token --resource https://confidential-ledger.azure.com

출력에서 원시 토큰 값을 복사합니다.

원장식별자 다운로드

원장은 서비스 증명서라는 인증서로 고유하게 식별됩니다. 원장에 대한 보안 연결을 설정하는 데 사용됩니다. 잘 알려진 엔드포인트에서 다운로드하고 servicer_cert.pem에 저장합니다.

비고

contoso 는 원장의 이름입니다. 적절한 원장 이름으로 바꿉니다.

curl https://identity.confidential-ledger.core.azure.com/ledgerIdentity/contoso --silent | jq ' .ledgerTlsCertificate' | xargs echo -e > service_cert.pem

애플리케이션 배포

/app/userDefinedEndpoints 엔드포인트를 호출하여 JavaScript 애플리케이션 번들을 배포합니다.

apiVersion="2024-08-22-preview"
content_type_application_json="Content-Type: application/json"
bundle="/path/to/bundle.json"
authorization="Authorization: Bearer raw_token_value"
server_identity="--cacert service_cert.pem"

# Deploy the application
#
curl $server_identity -X PUT "https://contoso.confidential-ledger.azure.com/app/userDefinedEndpoints?api-version=$apiVersion" -H "$content_type_application_json" -H "$authorization" -d @$bundle

# View the application
#
curl $server_identity "https://contoso.confidential-ledger.azure.com/app/userDefinedEndpoints?api-version=$apiVersion" -H "$authorization"

비고

고급 사용자 정의 함수 및 간단한 사용자 정의 함수는 상호 배타적인 기능입니다. 고급 UDF가 정의된 경우 간단한 UDF를 만들거나 실행할 수 없으며 그 반대의 경우도 마찬가지입니다. 둘 사이를 전환하려면 UDF 개요 페이지의 지침을 따릅니다.

역할 및 사용자 만들기

은행 애플리케이션은 관리자텔러라는 두 개의 가상 사용자를 사용합니다. 역할을 나타내기 위해 역할과 사용자를 만듭니다.

비고

각 사용자는 고유한 인증서로 표시됩니다.

비고

애플리케이션 사용자에게는 관리자, 기여자 및 읽기 권한자 등의 기본 제공 역할이 할당될 수 있습니다. 사용자 지정 역할은 대/소문자를 구분하며 기본 제공 역할은 대/소문자를 구분하지 않습니다. 사용자에게 여러 역할을 할당할 수 있습니다.

apiVersion="2024-08-22-preview"
content_type_application_json="Content-Type: application/json"
content_type_merge_patch_json="Content-Type: application/merge-patch+json"
authorization="Authorization: Bearer raw_token_value"
curve="secp384r1"
server_identity="--cacert service_cert.pem"

# These actions must match (case-sensitive) the values defined in the application.
#
role_actions='{"roles":[{"role_name":"manager","role_actions":["/banking/accounts/post","/banking/accounts/put","/banking/accounts/get","/banking/accounts/patch"]},{"role_name":"teller","role_actions":["/banking/accounts/put","/banking/accounts/get","/banking/accounts/patch"]}]}'

# Create the roles.
#
curl $server_identity -X PUT "https://contoso.confidential-ledger.azure.com/app/roles?api-version=$apiVersion" -H "$content_type_application_json" -H "$authorization" -d $role_actions

# View the roles
#
curl $server_identity "https://contoso.confidential-ledger.azure.com/app/roles?api-version=$apiVersion" -H "$authorization"

# Create a certificate for the manager user.
#
openssl ecparam -out "manager_privk.pem" -name "$curve" -genkey
openssl req -new -key "manager_privk.pem" -x509 -nodes -days 365 -out "manager_cert.pem" -sha384 -subj=/CN="manager"
manager_cert_fingerprint=$(openssl x509 -in "manager_cert.pem" -noout -fingerprint -sha256 | cut -d "=" -f 2)
manager_user="{\"user_id\":\"$manager_cert_fingerprint\",\"assignedRoles\":[\"manager\"]}"

# Create a certificate for the teller user.
#
openssl ecparam -out "teller_privk.pem" -name "$curve" -genkey
openssl req -new -key "teller_privk.pem" -x509 -nodes -days 365 -out "teller_cert.pem" -sha384 -subj=/CN="teller"
teller_cert_fingerprint=$(openssl x509 -in "teller_cert.pem" -noout -fingerprint -sha256 | cut -d "=" -f 2)
teller_user="{\"user_id\":\"$teller_cert_fingerprint\",\"assignedRoles\":[\"teller\"]}"

# Create the manager user.
#
curl $server_identity -X PATCH "https://contoso.confidential-ledger.azure.com/app/ledgerUsers/$manager_cert_fingerprint?api-version=$apiVersion" -H "$content_type_merge_patch_json" -H "$authorization" -d $manager_user

# Create the teller user.
#
curl $server_identity -X PATCH "https://contoso.confidential-ledger.azure.com/app/ledgerUsers/$teller_cert_fingerprint?api-version=$apiVersion" -H "$content_type_merge_patch_json" -H "$authorization" -d $teller_user

# View the users
#
curl $server_identity "https://contoso.confidential-ledger.azure.com/app/ledgerUsers?api-version=$apiVersion" -H "$authorization"

런타임 구성 업데이트(선택 사항)

/app/userDefinedEndpoints/runTimeOptions 엔드포인트를 호출하여 JavaScript 런타임 구성을 업데이트할 수 있습니다. 이를 보여주기 위해 최대 실행 시간을 2,000ms로 설정해 보겠습니다.

apiVersion="2024-08-22-preview"
content_type_merge_patch_json="Content-Type: application/merge-patch+json"
authorization="Authorization: Bearer raw_token_value"
runtime_options="{\"max_heap_bytes\":1024,\"max_stack_bytes\":1024,\"max_execution_time_ms\":2000,\"log_exception_details\":false,\"return_exception_details\":false,\"max_cached_interpreters\":1024}"
server_identity="--cacert service_cert.pem"

# Patch the runtime options
#
curl $server_identity -X PATCH "https://contoso.confidential-ledger.azure.com/app/userDefinedEndpoints/runTimeOptions?api-version=$apiVersion" -H "$content_type_merge_patch_json" -H "$authorization" -d $runtime_options

# View the runtime options
#
curl $server_identity "https://contoso.confidential-ledger.azure.com/app/userDefinedEndpoints/runTimeOptions?api-version=$apiVersion" -H "$authorization"

이제 애플리케이션 엔드포인트를 호출하고 트랜잭션을 제출할 준비가 되었습니다.

자원을 정리하세요

이 컬렉션의 다른 빠른 시작과 자습서는 이 빠른 시작을 기반으로 하여 작성됩니다. 이후의 빠른 시작 및 자습서를 계속 진행하려는 경우 이러한 리소스를 유지하는 것이 좋습니다.

더 이상 필요하지 않은 경우 Azure CLI az group delete 명령을 사용하여 리소스 그룹 및 모든 관련 리소스를 제거할 수 있습니다.

az group delete --name "myResourceGroup"

다음 단계

이 자습서에서는 사용자 지정 JavaScript 애플리케이션을 기밀 원장 인스턴스에 배포했습니다. Azure 기밀 원장 및 애플리케이션과 통합하는 방법에 대해 자세히 알아보려면 다음 문서를 계속 진행하세요.