Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-sqlcmd can't decrypt data if we use access token instead of connection string #83

Open
sejagada opened this issue Jun 7, 2024 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@sejagada
Copy link

sejagada commented Jun 7, 2024

Problem Statement
If we use connectionstring with Invoke-sqlcmd, we can specify "Column Encryption Setting = Enabled" to view plain text data if the column is encrypted.

 $connStr = "Server=$serverInstance;Database=$tDBName;User Id=$($adminUsername);Password=$($adminPassword);Column Encryption Setting=Enabled;TrustServerCertificate=true;"
 Invoke-Sqlcmd -ConnectionString $connStr -Query "SELECT [$columnName] FROM [$tableName]"

But if we use Access token instead of connection string, there is no way to specify "Column Encryption Setting = Enabled" due to which only encrypted data is displayed & it never tries to decrypt the data.

Connect-AzAccount
$access_token = (Get-AzAccessToken -ResourceUrl 'https://database.windows.net').Token
Invoke-Sqlcmd -ServerInstance $serverInstance -Database $AEPSTestDBName -AccessToken $access_token -Query "SELECT [$column1Name] FROM [$tableName]"

Expected: We should be able to set "Column Encryption Setting = Enabled" so that we can view decrypted/plain text data.
Actual: Cannot set "Column Encryption Setting = Enabled", so only encrypted data is visible to the user.

@Matteo-T Matteo-T assigned Matteo-T and sejagada and unassigned Matteo-T Jul 4, 2024
@Matteo-T Matteo-T added this to the v22.4 milestone Jul 4, 2024
@Matteo-T Matteo-T added the bug Something isn't working label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants