Am using azure keyvault to store my db username , url & password. I am using
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-starter-keyvault-secrets</artifactId>
</dependency>
this dependency to read the values configured in keyvaults in my spring boot application. But am getting Failed to determine suitable jdbc url error when the application loads. Can anyone help me one this
2
Answers
spring-cloud-azure-starter-keyvault-secrets
fetches values from the keyvault and makes them available as properties, but you have to use the properties somewhere.You seem to be missing the basic datasource configuration. Assuming the keyvault contains entries for
spring-datasource-url
,db-username
anddb-password
, inapplication.yml
(or equivalent) you need somethings like:There could be a possibility that you might have given wrong MS SQL URL, that might be causing to throw the above exception.
you can refer to the GITHUB documentation which I have followed.
I have tried the same from my end and got expected results:
Step 1:
Open the Azure Cloud Shell and run below command to get list of subscriptions
az account list
Step 2:
Setting the perticular Subscription
az account set -s your_subscription_id
Step 3 :
Creating service principal
az ad sp create-for-rbac --name myapp --role Contributor --scopes /subscriptions/mySubscriptionID
Step 4 :
Follow Below Steps:
Step 5:
Now Copy Your Client_ID, Your Client_Secret_Value, Your Tenant_ID and Key Vault URL in Spring Boot application Under resources folder in application.properties file like below:
Output: