Reputation: 1
I'm encountering an issue with my Azure DevOps pipeline where I'm trying to run a snowsql
command with a password retrieved from Azure Key Vault. The pipeline retrieves the secret correctly, but when I use it in the snowsql
command, I get an error stating that the password is not an integer.
Here is the relevant part of my pipeline script:
- script: |
export PATH=$PATH:~/snowflake
echo "Running Snowflake Initialization Scripts..."
~/snowflake/snowsql -a "$SNOWSQL_ACCOUNT" -u "$SNOWSQL_USER" -r "$SNOWSQL_ROLE" -w "$SNOWSQL_WAREHOUSE" -p "$(SnowflakePassword)" -f scripts/1_initialize_db.sql
displayName: 'Run Snowflake Initialization Scripts'
Error message:
Running Snowflake Initialization Scripts...
<my snowflake secret password> is not a valid integer
Try "snowsql --help" for more information.
##[error]Bash exited with code '2'.
I am seeing the secret value in the error so I am getting it back. Just not sure how to update the script to not capture as an integer.
What I've tried:
Get
and List
permissions for the secret.Observations
Additional information:
snowsql
command.Question
How can I correctly pass the password retrieved from Azure Key Vault to the snowsql
command in my Azure DevOps pipeline without encountering the "not an integer" error?
Thank you for your help!
Upvotes: 0
Views: 242
Reputation: 9798
-p is a parameter for the port number, not the password. The documentation explains how to use passwords with SnowSQL: https://docs.snowflake.com/en/user-guide/snowsql-start#specifying-passwords-when-connecting
Upvotes: 2
Reputation: 18094
Consider setting environment variables at the task level - it might help to avoid issues such as encoding, special characters, etc.
Instead of specifying the password in the command line:
- script: |
export PATH=$PATH:~/snowflake
echo "Running Snowflake Initialization Scripts..."
~/snowflake/snowsql ... -p "$(SnowflakePassword)" ...
displayName: 'Run Snowflake Initialization Scripts'
Try using the SNOWSQL_PWD
environment variable, as per Specifying passwords when connecting:
- script: |
export PATH=$PATH:~/snowflake
echo "Running Snowflake Initialization Scripts..."
# snowsql command WITHOUT the -p option
~/snowflake/snowsql ...
displayName: 'Run Snowflake Initialization Scripts'
env:
SNOWSQL_PWD: $(SnowflakePassword) # <----------------- set environment variable
Upvotes: 1