Store your connection string elements as Azure Key Vault secrets
Now that your Key Vault provisioning is completed, you need to add to it a secret containing the connection string to the database hosted by Azure Database for MySQL Single Server. You can use the following guidance to perform this task:
These secrets should be called SPRING-DATASOURCE-URL
, SPRING-DATASOURCE-USERNAME
and SPRING-DATASOURCE-PASSWORD
.
Step by step guidance
-
Add the url, username and password of the Azure Database for MySQL Flexible Server admin account as secrets to your Key Vault by running the following commands from the Git Bash prompt:
az keyvault secret set \ --name SPRING-DATASOURCE-URL \ --value "jdbc:mysql://$MYSQL_SERVER_NAME.mysql.database.azure.com:3306/$DATABASE_NAME?useSSL=true&serverTimezone=UTC" \ --vault-name $KEYVAULT_NAME az keyvault secret set \ --name SPRING-DATASOURCE-USERNAME \ --value $MYSQL_ADMIN_USERNAME \ --vault-name $KEYVAULT_NAME az keyvault secret set \ --name SPRING-DATASOURCE-PASSWORD \ --value $MYSQL_ADMIN_PASSWORD \ --vault-name $KEYVAULT_NAME