Azure Cloud HSM을 사용하면 모든 키, 버전, 특성, 태그 및 역할 할당을 유지하는 방식으로 HSM(하드웨어 보안 모듈)을 백업하고 복원할 수 있습니다.
이 자습서에서는 다음을 수행합니다.
- 클라우드 HSM 리소스에 대한 관리 ID 및 스토리지 계정을 만듭니다.
- 원본 클라우드 HSM 리소스에서 백업을 시작합니다.
- 대상 클라우드 HSM 리소스에 대한 복원을 시작하고 유효성을 검사합니다.
중요합니다
클라우드 HSM 백업을 만들 때 HSM 내에서 파생된 키가 이를 보호하는 데 도움이 됩니다. Microsoft는 파생 키에 대한 가시성 또는 액세스 권한이 없습니다.
사전 요구 사항
- 활성 구독이 있는 Azure 계정. 무료로 계정을 만들 수 있습니다.
- Azure Blob Storage는 역할 기반 접근 제어(RBAC)와 저장소 Blob 데이터 기여자 역할을 사용합니다.
지원되지 않는 구성
Azure Cloud HSM은 다음을 지원하지 않습니다.
- 원본 클라우드 HSM 리소스 또는 이미 활성화된 클라우드 HSM 리소스로 백업 복원 복원하려면 기본 설정 지역에서 다른 비활성 클라우드 HSM 리소스를 사용합니다. 그렇지 않으면 복원 작업이 실패하여 대상 Cloud HSM 리소스가 작동하지 않게 됩니다.
- 스토리지 컨테이너에 대한 SAS(공유 액세스 서명) 토큰을 통해 백업 및 복원합니다.
관리 ID 적용 및 스토리지 계정 만들기
다음 섹션의 코드를 사용하여 Azure Cloud HSM에 관리 ID를 적용하고 HSM 백업에 대한 스토리지 계정을 만듭니다.
관리 ID 만들기
기존 Azure Cloud HSM 리소스 그룹에 새 사용자 할당 관리 ID를 만듭니다. 이 자습서에서는 관리 ID CHSM-MSI 의 이름과 리소스 그룹의 이름으로 사용할 CHSM-SERVER-RG 수 있습니다.
CHSM-SERVER-RG 는 Azure Cloud HSM 온보딩 가이드 에서 예제 리소스 그룹으로 사용하는 이름입니다.
# Define parameters for the new managed identity
$identity = @{
Location = "<location>"
ResourceName = "<managed-identity-name>"
ResourceGroupName = "<resource-group>"
SubscriptionID = "<subscription-id>"
}
# Create a new user-assigned managed identity in the specified resource group and location
New-AzUserAssignedIdentity -Name $identity.ResourceName -ResourceGroupName $identity.ResourceGroupName -Location $identity.Location
클라우드 HSM 리소스에 관리 ID 적용
Azure Cloud HSM 백업 및 복원 작업의 경우 원본 및 대상 클라우드 HSM 리소스 모두에 관리 ID를 적용해야 합니다.
메모
대상 클라우드 HSM 리소스는 NotActivated 상태에 있어야 합니다.
각 클라우드 HSM 클러스터에는 하나의 관리 ID만 있을 수 있습니다. 원본 및 대상 모두에 대해 동일한 관리 ID를 사용하거나 각각에 대해 다른 관리 ID를 사용할 수 있습니다. 이 자습서의 예제에서는 원본 및 대상 클라우드 HSM 리소스 모두에 동일한 관리 ID를 적용합니다.
# Define the parameters for the source Cloud HSM resource
$sourceCloudHSM = @{
Location = "<location>"
Sku = @{ "family" = "B"; "Name" = "Standard_B1" }
ResourceName = "<source-hsm-name>"
ResourceType = "microsoft.hardwaresecuritymodules/cloudHsmClusters"
ResourceGroupName = "<source-resource-group>"
Force = $true
}
# Define the parameters for the destination Cloud HSM resource
$destinationCloudHSM = @{
Location = "<location>"
Sku = @{ "family" = "B"; "Name" = "Standard_B1" }
ResourceName = "<destination-hsm-name>"
ResourceType = "microsoft.hardwaresecuritymodules/cloudHsmClusters"
ResourceGroupName = "<destination-resource-group>"
Force = $true
}
# Define the Cloud HSM managed identity patch payload
$chsmMSIPatch = '{
"Sku": {
"Family": "B",
"Name": "Standard_B1"
},
"Location": "<location>",
"Identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/<subscription-id>/resourcegroups/<resource-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<managed-identity-name>": {}
}
}
}'
# Construct the source URI
$sourceURI = "/subscriptions/$($identity.SubscriptionID)/resourceGroups/$($sourceCloudHSM.ResourceGroupName)/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/$($sourceCloudHSM.ResourceName)?api-version=2025-03-31"
# Construct the destination URI
$destinationURI = "/subscriptions/$($identity.SubscriptionID)/resourceGroups/$($destinationCloudHSM.ResourceGroupName)/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/$($destinationCloudHSM.ResourceName)?api-version=2025-03-31"
# Invoke the REST method to update the source Cloud HSM resource with the managed identity patch
Invoke-AzRestMethod -Path $sourceURI -Method Put -Payload $chsmMSIPatch
# Invoke the REST method to update the destination Cloud HSM resource with the managed identity patch
Invoke-AzRestMethod -Path $destinationURI -Method Put -Payload $chsmMSIPatch
프라이빗 가상 네트워크에서 스토리지 계정 만들기
프라이빗 가상 네트워크 내에서 스토리지 계정 및 연결된 Blob 컨테이너를 정의하고 구성하여 Azure Cloud HSM 백업 작업에 대한 스토리지 인프라를 설정합니다.
먼저 구독 ID를 정의합니다. 위치, 제품 계층 및 유형을 포함하여 스토리지 계정 매개 변수를 지정합니다.
이 프로세스에는 새 리소스 그룹 만들기, 지정된 가상 네트워크에 대한 액세스를 제한하는 네트워크 규칙으로 스토리지 계정 설정, 프라이빗 엔드포인트를 통한 보안 강화 등이 포함됩니다. 스토리지 Blob 데이터 기여자 역할은 백업 작업에 대한 적절한 권한을 보장하기 위해 지정된 ID에 할당됩니다.
다음 코드에서는 다음 예제를 사용할 수 있습니다.
-
CHSM-BACKUP-RG리소스 그룹 이름을 위한 -
chsmbackup00스토리지 계정의 이름 -
chsmbackupcontainer00는 Blob 컨테이너의 이름입니다.
원본과 대상 모두에 대해 읽기/쓰기 액세스 권한이 부여됩니다.
중요합니다
필요한 최소 RBAC 역할은 Storage Blob 데이터 기여자입니다. 공용 스토리지 계정은 공용 인터넷을 통해 액세스할 수 있으므로 보안 강화를 위해 스토리지 계정을 프라이빗 가상 네트워크 뒤에 배치합니다.
# Define the subscription ID
$subscriptionId = "<subscription-id>"
# Define storage account parameters
$storageAccount = @{
Location = "<location>"
ResourceGroupName = "<backup-resource-group>"
AccountName = "<storage-account-name>" # Name of the storage account
SkuName = "<storage-sku>" # Storage account tier (example: Standard_LRS)
Kind = "<storage-type>" #Type of storage account (example: StorageV2)
}
# Define the blob container parameters
$container = @{
ResourceGroupName = $storageAccount.ResourceGroupName # Resource group name where the storage account is located
StorageAccountName = $storageAccount.AccountName # Name of the storage account
ContainerName = "<container-name>" # Name of the blob container
}
# Define the private endpoint parameters
# Storage accounts are publicly accessible, so put it behind a private virtual network
$privateEndpoint = @{
Name = "<private-endpoint-name>"
VnetName = "<vnet-name>" # Name of the existing virtual network
SubnetName = "<subnet-name>" # Name of the existing subnet within the virtual network
ResourceGroupName = "<resource-group>" # Resource group for private virtual network and subnet (example: CHSM-CLIENT-RG)
}
# Define the role assignment parameters
$roleAssignment = @{
RoleDefinitionName = "Storage Blob Data Contributor" # Minimum RBAC role required
PrincipalId = "<principal-id>" # The ID of the managed identity or user to assign the role to
Scope = "/subscriptions/$($subscriptionId)/resourceGroups/$($storageAccount.ResourceGroupName)/providers/Microsoft.Storage/storageAccounts/$($storageAccount.AccountName)"
}
# Create a new resource group with the specified name and location
New-AzResourceGroup -Name $storageAccount.ResourceGroupName -Location $storageAccount.Location -Force
# Create a new storage account in the specified resource group and location
# This command sets up the storage account needed for backup operations
New-AzStorageAccount -ResourceGroupName $storageAccount.ResourceGroupName `
-Name $storageAccount.AccountName `
-Location $storageAccount.Location `
-SkuName $storageAccount.SkuName `
-Kind $storageAccount.Kind
# Retrieve the storage account key
$storageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $storageAccount.ResourceGroupName -Name $storageAccount.AccountName)[0].Value
# Create the storage context
$storageAccountContext = New-AzStorageContext -StorageAccountName $storageAccount.AccountName -StorageAccountKey $storageAccountKey
# Create the blob container in the storage account
New-AzStorageContainer -Name $container.ContainerName -Context $storageAccountContext
# Retrieve the virtual network and subnet object
$vnet = Get-AzVirtualNetwork -ResourceGroupName $privateEndpoint.ResourceGroupName -Name $privateEndpoint.VnetName
$subnet = $vnet.Subnets | Where-Object { $_.Name -eq $privateEndpoint.SubnetName }
# Create the private endpoint for the storage account in the existing virtual network
New-AzPrivateEndpoint -ResourceGroupName $storageAccount.ResourceGroupName `
-Name $privateEndpoint.Name `
-Location $storageAccount.Location `
-PrivateLinkServiceConnection @(
@{
Name = "$($storageAccount.AccountName)-connection"
PrivateLinkServiceConnectionState = @{
Status = "Approved"
Description = "Private Endpoint Connection"
}
PrivateLinkServiceId = "/subscriptions/$subscriptionId/resourceGroups/$($storageAccount.ResourceGroupName)/providers/Microsoft.Storage/storageAccounts/$($storageAccount.AccountName)"
GroupIds = @("blob") # Add this parameter with the required group ID
}
) `
-Subnet $subnet
# Assign the Storage Blob Data Contributor role to the specified identity
New-AzRoleAssignment -RoleDefinitionName $roleAssignment.RoleDefinitionName `
-PrincipalId $roleAssignment.PrincipalId `
-Scope $roleAssignment.Scope
포털 설정을 통해 공유 키 액세스 사용 안 함
공유 키 액세스를 사용하지 않도록 설정하여 보안을 강화합니다.
- Azure Portal에서 Azure Storage 계정으로 이동합니다.
- 설정>구성을 선택합니다.
- 스토리지 계정 키 액세스 허용을 비활성화로 설정합니다.
원본 클라우드 HSM 리소스에서 백업 시작
스토리지 컨테이너 URI가 있는 요청을 백업 API 엔드포인트로 전송 POST 하여 원본 클라우드 HSM 리소스에 대한 백업을 시작합니다. 응답 헤더의 URL에 GET 요청을 전송하여 백업의 진행률을 모니터링합니다.
다음 스크립트는 응답에서 백업 작업 상태 및 고유 백업 ID를 검색하고 보여 줍니다. 상태는 백업이 시작되었음을 확인하고 진행 상황을 추적합니다.
# Define backup properties, including the URI for the Azure Blob Storage container
$backupProperties = ConvertTo-Json @{
azureStorageBlobContainerUri = "https://$($container.StorageAccountName).blob.core.windows.net/$($container.ContainerName)"
}
# Construct the URI for the backup operation by using the provided parameters
$backupUri = "/subscriptions/$($identity.SubscriptionID)/resourceGroups/$($sourceCloudHSM.ResourceGroupName)/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/$($sourceCloudHSM.ResourceName)/backup?api-version=2025-03-31"
# Initiate the backup operation by sending a POST request with the backup properties
$response = Invoke-AzRestMethod -Path $backupUri -Method Post -Payload $backupProperties
# Check the backup job status to confirm that it succeeded
$jobStatus = Invoke-AzRestMethod -Method 'GET' -Uri $response.Headers.Location
$backupStatus = (ConvertFrom-Json $jobStatus.Content).properties.status
# Extract the backup ID from the job status response
$backupID = (ConvertFrom-Json $jobStatus.Content).properties.backupId
# Output the backup status and backup ID
$backupStatus
$backupID
예상 출력: $backupStatus 반환 Succeeded하고 $backupID 시작한 백업의 해당 ID를 표시합니다.
대상 클라우드 HSM 리소스에 대한 복원 시작
스토리지 컨테이너 URI 및 백업 ID를 포함하여 필요한 복원 속성을 제공하여 대상 클라우드 HSM 리소스에 대한 복원 작업을 시작합니다.
다음 스크립트는 복원 API 엔드포인트에 대한 올바른 URI를 POST 만들고 복원을 시작하기 위한 요청을 보냅니다. 복원 진행률을 모니터링하려면 응답 헤더에 지정된 위치에 요청을 보내고 GET 복원 작업 상태를 검색하여 완료를 확인합니다.
$restoreProperties = ConvertTo-Json @{
"azureStorageBlobContainerUri" = "https://$($container.StorageAccountName).blob.core.windows.net/$($container.ContainerName)"
"backupId" = "$($backupID)"
}
# Set the URI for the restore API endpoint by using the subscription ID, resource group, and destination server details
$restoreUri = "/subscriptions/$($identity.SubscriptionID)/resourceGroups/$($destinationCloudHSM.ResourceGroupName)/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/$($destinationCloudHSM.ResourceName)/restore?api-version=2025-03-31"
# Initiate the restore operation by sending a POST request to the restore API endpoint with the defined properties
$response = Invoke-AzRestMethod -Path $restoreUri -Method Post -Payload $restoreProperties
# Check the status of the restore job by sending a GET request to the location provided in the response headers
$jobStatus = Invoke-AzRestMethod -Method 'GET' -Uri $response.Headers.Location
# Extract and display the status of the restore job
(ConvertFrom-Json $jobStatus.Content).properties.status
예상 출력: $jobStatus 반환 Succeeded해야 합니다.
대상 클라우드 HSM 리소스에 대한 복원 유효성 검사
처리 시간이 지나면 복원 작업이 표시 Succeeded되어야 하며 대상 클라우드 HSM 리소스에 활성화 상태가 Active표시됩니다. 복원 작업을 수행한 대상 클라우드 HSM 리소스에 연결하면, azcloudhsm_mgmt_util 및 getClusterInfo를 실행했을 때 세 개의 노드가 모두 활성화되어 사용 가능한 상태로 나타나야 합니다.
중요합니다
관리 가상 머신에서 Azure Cloud HSM에 연결하는 경우 복원을 수행한 올바른 대상 Cloud HSM 리소스를 가리키도록 클라이언트 및 관리 구성 파일(azcloudhsm_resource.cfg)을 모두 업데이트합니다.
다음 명령 중 하나를 실행하여 시작
azcloudhsm_mgmt_util합니다.Linux:
cd /usr/local/bin/AzureCloudHSM-ClientSDK-* sudo ./azcloudhsm_mgmt_util ./azcloudhsm_resource.cfg윈도우:
cd azcloudhsm_mgmt_util .\azcloudhsm_mgmt_util.exe .\azcloudhsm_resource.cfg관리 도구 내의 프롬프트는
cloudmgmt로 설정됩니다. 클러스터 정보를 나열하려면 다음을 실행합니다.getClusterInfo예상 출력:
getClusterInfo이제 세 노드를 모두 Azure Cloud HSM 클러스터에 사용할 수 있는지 확인해야 합니다.관리 도구를 닫은 다음 Azure Cloud HSM 도구(
azcloudhsm_util)를 엽니다.CU로 로그인하고findKey명령을 실행합니다.중요합니다
키 핸들은 동적이므로 변경할 수 있습니다. 그러나 키 ID는 변경되지 않습니다.
Linux:
./azcloudhsm_util loginHSM -u CU -s cu1 -p user1234 findKey윈도우:
azcloudhsm_util.exe loginHSM -u CU -s cu1 -p user1234 findKey