-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG] Autowired doesn't work for @Repository using App configuration and Cosmos #33165
Comments
Hi, @survivant Did you do that? |
I did that and it works, but after that we are adding App configuration to the project. See the next steps there is also a sample that should contains the complete source code : https://github.com/Azure-Samples/azure-spring-boot-samples/tree/main/appconfiguration/azure-spring-cloud-appconfiguration-config/azure-spring-cloud-appconfiguration-config-convert-sample/azure-spring-cloud-appconfiguration-config-convert-sample-complete but that example doesn't include all the classes that were added in the initial. but the complete example contains this in the bootstrap.properties Probably there are 2 things that are not correct. #1 - probably the properties are required in bootstrap.properties ? |
I think you are right. There is some problem in current azure-spring-cloud-appconfiguration-config-convert-sample-complete. We will fix it. But now there is no ETA. If you are interested and willing to create PR to fix these problems, we will very appreciate it. If you plan to create a PR to fix it, please left a comment here to let others know. |
I'll do it no problem, it will be a pleasure. Can you confirm that I need to put the cosmos variables into bootstrap.properties. I'll try to create a PR soon. |
Thank you very much.
Actually, I'm not sure. I guess we should do these things:
Could you please try these changes and run the sample project, check whether these changes work? |
Hi @survivant, I think we can change the configurations names configured in App Configuration service should be:
And then we can delete these configuration properties from the spring.cloud.azure.cosmos.endpoint=${COSMOS-URL}
spring.cloud.azure.cosmos.key=${COSMOS-KEY}
spring.cloud.azure.cosmos.database=${COSMOS-DATABASENAME} Because now these properties can be fetched via the Spring Cloud App Configuration config library. As for the credential, if you using App Configuration with KV, you need to provide credentials for both App Configuration and Key Vault, hence the But according to your For For |
A better option would be use return new DefaultAzureCredentialBuilder()
.build(); It will search Azure credentials from several places, logged-in users from Azure CLI/Azure Powershell/Intellij, Environment variables, or Azure Managed Identity. And you could assign the data read roles of App Configuration and Key Vault to yourself. So when you developing locally, you don't need to provide environment variables, such See Spring Cloud Azure authentication and Role Assignment for more details. |
if I return to usecase #1 here the configuration that I have I know, I could delete the old keys, but I'll do it later and for the bootstrap.properties, all the lines are comments except for the connection-string |
@survivant you can remove the connection string from the |
I tried to ran the terraform script from : azure-spring-boot-samples\appconfiguration\spring-cloud-azure-starter-appconfiguration\appconfiguration-client and was hoping to be able to modify it and add it to this issue, so you could have been able to ran it youself and see the errors live. PS. It's my first time with terraform. I did this
but when I do
maybe some steps are missing from the readme PS. I'm already logged with |
But do you still have this |
Not sure what's wrong with the cosmos connection, could you try to add this |
I'll try that line tomorrow. But I can say that the connection works when we don't use App configuration ( like in the initial sample). I'll try to run it in trace mode to see if there are messages that could help. |
Can the same application work if the |
if I take the initialSample (without AppConfiguration) and put my info in application.properties, it works fine
|
Could you try to run the complete sample (the one with App Configuration), and also configure the Or is it possible that you can share a minimal project for me to reproduce the issue? For there was no connection issue when I ran the sample (the zipped file) you provided initially? |
here a new sample. I took the source code from github and added the missing classes in complete and added the missing configuration in properties files. here a export of my Appconfiguration key/values (modified)
|
If you move the code in the From: @PostConstruct
public void setup() {
// For this example, remove all of the existing records.
this.repository.deleteAll().block();
} To public void run(String... var1) throws Exception {
this.repository.deleteAll().block();
} |
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
I'm still working on that. I created a terraform script to create the resources, but I have trouble getting the AZURE_CLIENT_SECRET value for the spring boot apps. I think I'll have to create a service principal instead of just assigning role. Hope to get something soon |
here a standalone project.
terraform-appconfig-cosmos.zip With that we should have the exact same setup. |
What's the issue right now? I checked the demo, the |
thanks you ! I needed a second pair of eyes. Now the Autowired works in the run() method. I'll do a second test within a RestController. It should works. After that, I'll work on the documentation and source code modification for a PR. thanks for your time. |
Glad to hear that, I am going to close this issue now. |
Describe the bug
Unable to start the application when I activate the App configuration. I started from an example (https://github.com/Azure-Samples/azure-spring-boot-samples/tree/main/appconfiguration/azure-spring-cloud-appconfiguration-config/azure-spring-cloud-appconfiguration-config-convert-sample/azure-spring-cloud-appconfiguration-config-convert-sample-initial) but I got the Autowired error, so I look around and found another git repository that had a working example with App configuration, but as soon as I added Cosmos, I got the same error.
azure-app-configuration-with-cosmos.zip I opened a issue there too, to see if I missed something (csu-devsquad-latam/java-spring-boot-app-config#7)
there are 4 environments variables to setup and after that you run the program with
mvn spring-boot:run
Exception or Stack Trace
To Reproduce
added the environment variables and
mvn spring-boot:run
Code Snippet
I apply all the steps that were in the readme.md : https://github.com/Azure-Samples/azure-spring-boot-samples/tree/main/appconfiguration/azure-spring-cloud-appconfiguration-config/azure-spring-cloud-appconfiguration-config-convert-sample/azure-spring-cloud-appconfiguration-config-convert-sample-initial
Expected behavior
the application should works
Setup (please complete the following information):
Additional context
I replaced my endpoint by : https://XXX.azconfig.io in those logs
Information Checklist
The text was updated successfully, but these errors were encountered: