I am looking for a secure way to have a script running on a local machine and authenticate using these commands in Azure :
$Password = ConvertTo-SecureString -AsPlainText "my_secret" -Force
$Credential = New-Object System.Management.Automation.PSCredential ("my_client_id", $Password)
$TenantId = "my_tenant_id"
Connect-AzAccount -ServicePrincipal -Credential $Credential -Tenant $TenantId
The issue is that I do not want to save the secret as plain text in the script. The only solution I have found was to encrypt SecureString password and save it in a file that can be decrypted using a key. This way, the secret is never in plain text.
Is there any other "clean" way to do this?
Thanks !