자동화에서 Azure Key Vault 사용

이 문서에서는 자동화 시나리오에서 Azure Key Vault 사용하는 예제를 제공합니다. Azure Key Vault 로컬 머신 외부에 저장된 암호, 토큰 및 기타 비밀을 안전하게 저장 및 검색하고 자동화 파이프라인에서 사용할 수 있는 방법을 제공합니다.

자동화를 실행하는 호스트 설정

Az.KeyVault 3.3.0부터 모듈에는 SecretManagement cmdlet을 사용하여 Azure Key Vault 저장된 비밀과 상호 작용할 수 있는 SecretManagement 확장이 포함되어 있습니다.

먼저 Azure 구독에서 Key Vault 만들고 비밀을 추가해야 합니다. 자세한 내용은 빠른 시작: Azure PowerShell 사용하여 Azure Key Vault 키 설정 및 검색을 참조하세요.

SecretManagement와 함께 Azure Key Vault 사용하려면 먼저 Az.KeyVault 모듈이 있는지 확인합니다.

다음으로 , AZKVaultNameSubscriptionId를 사용하여 자격 증명 모음을 등록합니다. 이러한 명령은 자동화 호스트의 자동화 계정 사용자 컨텍스트에서 실행되어야 합니다.

Install-Module -Name Microsoft.PowerShell.SecretManagement -Repository PSGallery -Force
Install-Module Az.KeyVault -Repository PSGallery -Force
Import-Module Microsoft.PowerShell.SecretManagement
Import-Module Az.KeyVault

$VaultParameters = @{
    AZKVaultName = $vaultName
    SubscriptionId = $subID
}
Register-SecretVault -Module Az.KeyVault -Name AzKV -VaultParameters $VaultParameters

자동화에서 Azure Key Vault 비밀 사용

SecretManagement를 사용하여 Azure Key Vault 등록했으므로 를 사용하여 비밀을 보고, 을 Get-Secret사용하여 비밀을 Get-SecretInfo얻고, 를 사용하여 비밀을 만들고 업데이트하고, 을 Remove-Secret사용하여 비밀을 Set-Secret제거할 수 있습니다.