I'm working with a powershell script that I need to connect to SSISDB database via keyvault but getting error:
Exception calling "Open" with "0" argument(s): "Login failed for user ''."
Here is the connection string I'm using in code:
$env = Get-AutomationVariable -Name 'Env'
$vaultName = 'ab-'+$env.ToLower()+'-bi-keyvault'
$dataSource = 'ab'+$env.ToLower()+'dbserver01.database.windows.net'
Write-Output "vaultName: " $vaultName
$password = Get-AzKeyVaultSecret -VaultName $vaultName -Name 'DBPassword'
$userName = Get-AzKeyVaultSecret -VaultName $vaultName -Name 'DBUsername'
$passwordSecret = $password.SecretValueText
$userNameSecret = $userName.SecretValueText
##########################################################
Write-Output "SSISDB"
Write-Output "JOB START"
# Create connection to Master DB
$database = 'SSISDB'
Write-Output "Running job on " $database
$MasterDatabaseConnection = New-Object System.Data.SqlClient.SqlConnection
$MasterDatabaseConnection.ConnectionString = "Data Source=$dataSource;Initial Catalog=$database;Integrated Security=False;User ID=$userNameSecret ;Password=$passwordSecret ;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False"
If I check connection with using userid/password directly in code , it does work but not with keyvault. Do you have any idea that what is the issue with my code?
question from:
https://stackoverflow.com/questions/65940425/connection-to-sql-server-via-keyvault 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…