1

PowerShell 스크립트를 호출 할 Azure 함수를 만듭니다. 이렇게하려면 PS 스크립트에 무인 로그인을해야합니다. 그래서 다음과 같이 응용 프로그램 및 서비스 사용자를 만들었습니다.Powershell 스크립트 및 무인 로그인 호출 Azure 함수

# Create an Azure Active Directory Application that will be used for authentication in Powershell Automation scripts. 
$Password = ConvertTo-SecureString '<MyPassword>' -AsPlainText -Force 
$AzureAdApplication = New-AzureRmADApplication -DisplayName "PowerShellAdminApp" -Password $Password -HomePage "https://www.phoenix.com" -IdentifierUris "https://www.phoenix.com" 

# Create the Service Principal 
New-AzureRmADServicePrincipal -ApplicationId $AzureAdApplication.ApplicationId 

# Add permissions to the Server Principal 
New-AzureRmRoleAssignment -RoleDefinitionName Contributor -ServicePrincipalName $AzureAdApplication.ApplicationId.Guid 

이 모두 올바르게 작동합니다. 다음과 같이

그런 다음 내 PS 스크립트 (들)에, 나는, 무인에 기록합니다이뿐만 아니라 작동

$Username = "https://www.phoenix.com" 
$Password = ConvertTo-SecureString "<MyPassword>" -AsPlainText -Force 
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $Username, $Password 
Login-AzureRmAccount -ServicePrincipal -Credential $Credential -TenantId '<MyTenantId' 

. 그러나, 나는 뭔가를 이해하지 못하거나 뭔가를 놓치고있는 것처럼 느낍니다. 이것은 전혀 안전하지 않습니다. 모든 PS 스크립트에이 로그인 코드가 있어야한다면 기본적으로이 스크립트에 액세스 할 수있는 모든 사용자가 임차인 ID와 비밀번호를 볼 수 있도록 허용합니다. 그런 다음 앱에서 수행 할 수있는 모든 작업을 수행 할 수 있습니다.

이 작업을 올바르게하고 있습니까, 아니면 이해하지 못하고 있습니까?

+0

안녕하세요, PS 스크립트가 실행되는 위치에 따라 비밀번호를 저장하기 위해 Azure의 볼트를 사용할 수 있습니다. Azure MSI를 살펴보십시오. VM에서 활성화하면 사물을 안전하게 보호 할 수 있습니다. –

답변