[BUG] Autowired doesn't work for @Repository using App configuration and Cosmos
survivant opened this issue · 30 comments
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
$env:AZURE_CLIENT_ID="XXX"
$env:AZURE_CLIENT_SECRET="XXX"
$env:AZURE_TENANT_ID="XXX"
$env:APP_CONFIGURATION_ENDPOINT="XXX"
Exception or Stack Trace
Field repository in sample.convert.ConvertSampleApplication required a bean of type 'sample.convert.UserRepository' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
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):
- OS: Windows 10
- IDE: IntelliJ
- Sample Path:
- Library/Libraries: com.azure.spring:spring-cloud-azure-starter-data-cosmos:4.5.0, com.azure.spring:azure-spring-cloud-appconfiguration-config:2.11.0
- Java version: 17
- Frameworks: Spring Boot 2.7.8
Additional context
I replaced my endpoint by : https://XXX.azconfig.io in those logs
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.8)
2023-01-25 10:57:35.549 INFO 14876 --- [ main] c.azure.identity.EnvironmentCredential : Azure Identity => EnvironmentCredential invoking ClientSecretCredential
2023-01-25 10:57:35.562 INFO 14876 --- [ main] c.a.c.i.jackson.JacksonVersion : Package versions: jackson-core=2.13.4, jackson-databind=2.13.4-2, jackson-dataformat-xml=2.13.4, jackson-datatype-jsr310=2.13.4, azure-core=1.34.0, Troubleshooting version conflicts: https://aka.ms/azsdk/java/de
pendency/troubleshoot
2023-01-25 10:57:36.931 INFO 14876 --- [nPool-worker-19] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [https://XXX.azconfig.io/.default]: SUCCESS
2023-01-25 10:57:36.932 INFO 14876 --- [nPool-worker-19] c.a.c.implementation.AccessTokenCache : Acquired a new access token.
2023-01-25 10:57:37.062 INFO 14876 --- [ main] c.azure.identity.EnvironmentCredential : Azure Identity => EnvironmentCredential invoking ClientSecretCredential
2023-01-25 10:57:37.492 INFO 14876 --- [nPool-worker-19] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [https://vault.azure.net/.default]: SUCCESS
2023-01-25 10:57:37.492 INFO 14876 --- [nPool-worker-19] c.a.c.implementation.AccessTokenCache : Acquired a new access token.
2023-01-25 10:57:37.545 INFO 14876 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-/application/https://XXX.azconfig.io/'}]
2023-01-25 10:57:37.548 INFO 14876 --- [ main] sample.convert.ConvertSampleApplication : No active profile set, falling back to 1 default profile: "default"
2023-01-25 10:57:37.855 INFO 14876 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=15f9cc46-5654-3bd0-8948-a145c05c5920
2023-01-25 10:57:37.893 WARN 14876 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'convertSampleApplication': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'sample.convert.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springf
ramework.beans.factory.annotation.Autowired(required=true)}
2023-01-25 10:57:37.900 INFO 14876 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-25 10:57:37.913 ERROR 14876 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field repository in sample.convert.ConvertSampleApplication required a bean of type 'sample.convert.UserRepository' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'sample.convert.UserRepository' in your configuration.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.674 s
[INFO] Finished at: 2023-01-25T10:57:38-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.7.8:run (default-cli) on project azure-spring-cloud-appconfiguration-config-convert-sample-initial: Application finished with exit code: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
PS C:\to-delete\azure-spring-boot-samples\appconfiguration\azure-spring-cloud-appconfiguration-config\azure-spring-cloud-appconfiguration-config-convert-sample\azure-spring-cloud-appconfiguration-config-convert-sample-initial>
Information Checklist
- [ X] Bug Description Added
- [ X] Repro Steps Added
- [ X] Setup information Added
Hi, @survivant
Thanks for reaching out.
According to the README.md, it's necessary to add these properties in the application.properties:
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 ?
#2 - the complete sample doesn't include the source code that was added in the initial steps
Probably there are 2 things that are not correct.
#1 - probably the properties are required in bootstrap.properties ?
#2 - the complete sample doesn't include the source code that was added in the initial steps
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.
I'll do it no problem, it will be a pleasure.
Thank you very much.
Can you confirm that I need to put the cosmos variables into bootstrap.properties.
Actually, I'm not sure. I guess we should do these things:
- Use
spring.cloud.azure.appconfiguration.stores[0].endpoint
instead ofspring.cloud.azure.appconfiguration.stores[0].connection-string
- Add related Java code written in the initial sample's README.
Could you please try these changes and run the sample project, check whether these changes work?
Here all the tests that I tried.
I set those environnement variables and try those examples
(yes I used the real values :) )
$env:AZURE_CLIENT_ID="XXX"
$env:AZURE_CLIENT_SECRET="YYY"
$env:AZURE_TENANT_ID="ZZZ"
use case 1
use case 2
I omited the configuration file
use case 3
usecase 4
not sure what I can try next
Hi @survivant, I think we can change the configurations names configured in App Configuration service should be:
/application/spring.cloud.azure.cosmos.endpoint
/application/spring.cloud.azure.cosmos.database
/application/spring.cloud.azure.cosmos.key
And then we can delete these configuration properties from the bootstrap.properties
file:
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 AppConfigurationCredentialProvider
and KeyVaultCredentialProvider
.
But according to your case 1
, you are providing both connection string and credential for App Configuration, so it throws exception. Because the connection string also contains credential info.
For case 2
and case 3
, you are not providing credential for KV, so it will try the Azure Managed Identity to do the authentication, which is not availble on your local machine. So they both failed.
For case 4
, the App Configration requires the bootstrap.proeprties
.
A better option would be use DefaultAzureCredential
:
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 AZURE_CLIENT_ID
. As long as you have logged in to Azure CLI, it can use that credential.
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 bootstrap.properties
, because you have already provided an implementation of the AppConfigurationCredentialProvider
.
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
choco install terraform
terraform init
terraform -upgrade`
but when I do terraform plan
I obtain those errors
PS C:\to-delete\azure-spring-boot-samples\appconfiguration\spring-cloud-azure-starter-appconfiguration\appconfiguration-client\terraform> terraform plan
╷
│ Error: Failed to load plugin schemas
│
│ Error while loading schemas for plugin components: 2 problems:
│
│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/aztfmod/azurecaf: failed to instantiate provider "registry.terraform.io/aztfmod/azurecaf" to obtain schema: Unrecognized remote plugin message:
│
│ This usually means that the plugin is either invalid or simply
│ needs to be recompiled to support the latest protocol..
│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/azurerm: failed to instantiate provider "registry.terraform.io/hashicorp/azurerm" to obtain schema: Unrecognized remote plugin message:
│
│ This usually means that the plugin is either invalid or simply
│ needs to be recompiled to support the latest protocol...
╵
PS C:\to-delete\azure-spring-boot-samples\appconfiguration\spring-cloud-azure-starter-appconfiguration\appconfiguration-client\terraform>
maybe some steps are missing from the readme
PS. I'm already logged with az login
By putting that line in comment, all my lines are commented. If I run the application I'll obtain the error below. (because my boostrap.properties contains only commented lines, I try another thing.. delete the file and run again the application and the result is the same)
But do you still have this spring.cloud.azure.appconfiguration.stores[0].endpoint=${APP_CONFIGURATION_ENDPOINT}
?
Nice, the application is now starting.. but look like the application doesn't start completly.
I opened a new terminal. Put the environment variables in the terminal. Start the application in debug (with suspend=y)
mvnDebug spring-boot:run
I connected with Remote JVM debug.. but none of the breakpoints are reached.
look like the application is stucked at : Endpoint$RntbdEndpointMonitoringProvider : Starting RntbdClientChannelPoolMonitoringProvider ...
Not sure what's wrong with the cosmos connection, could you try to add this spring.cloud.azure.cosmos.connection-mode=gateway
to your application.properties
or bootstrap.properties
? If it doesn't work, we can add the Cosmos team to help troubleshoot.
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.
I don't get the same error, but it still stall somewhere and it's not going into the main in the App. I added DEBUG logger to see what going on. I even created my database/container just to be sure (but it they will be created and the main program run)
I added 2 System.out to see if they will appear in the logs
Only the System.out of the main that is called.
it really looks like the run method
in @SpringBootApplication
is never call
PS. I check also that my IP is allow in Cosmos Networking
IN THE MAIN!!!!!!!!!!!!!!!07:04:12.121 [background-preinit] INFO o.h.validator.internal.util.Version - HV000001: Hibernate Validator 6.2.5.Final
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.8)
06:54:33.033 [main] DEBUG c.a.identity.EnvironmentCredential - Azure Identity => Found the following environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
06:54:33.034 [main] INFO c.a.identity.EnvironmentCredential - Azure Identity => EnvironmentCredential invoking ClientSecretCredential
06:54:33.044 [main] INFO c.a.c.i.jackson.JacksonVersion - Package versions: jackson-core=2.13.4, jackson-databind=2.13.4-2, jackson-dataformat-xml=2.13.4, jackson-datatype-jsr310=2.13.4, azure-core=1.34.0, Troubleshooting version conflicts: https://aka.ms/azsdk/java/dependency/troubleshoot
06:54:33.086 [main] DEBUG c.a.s.c.c.i.AppConfigurationReplicaClientsBuilder - Connecting to https://XXXX.azconfig.io using AppConfigurationCredentialProvider.
06:54:33.105 [main] DEBUG c.a.c.i.http.HttpClientProviders - Using com.azure.core.http.netty.NettyAsyncHttpClientProvider as the default HttpClientProvider.
06:54:34.142 [ForkJoinPool.commonPool-worker-19] INFO c.a.identity.ClientSecretCredential - Azure Identity => getToken() result for scopes [https://XXXX.azconfig.io/.default]: SUCCESS
06:54:34.144 [ForkJoinPool.commonPool-worker-19] INFO c.a.c.i.AccessTokenCache - Acquired a new access token.
06:54:34.267 [reactor-http-nio-2] DEBUG c.a.c.i.h.r.ReflectionSerializable - JsonSerializable serialization and deserialization isn't supported. If it is required add a dependency of 'com.azure:azure-json', or another dependencies which include 'com.azure:azure-json' as a transitive dependency. If your applicat
ion runs as expected this informational message can be ignored.
06:54:34.268 [reactor-http-nio-2] DEBUG c.a.c.i.h.r.ReflectionSerializable - XmlSerializable serialization and deserialization isn't supported. If it is required add a dependency of 'com.azure:azure-xml', or another dependencies which include 'com.azure:azure-xml' as a transitive dependency. If your application
runs as expected this informational message can be ignored.
06:54:34.286 [main] DEBUG c.a.identity.EnvironmentCredential - Azure Identity => Found the following environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
06:54:34.288 [main] INFO c.a.identity.EnvironmentCredential - Azure Identity => EnvironmentCredential invoking ClientSecretCredential
06:54:34.301 [main] DEBUG c.a.s.k.s.i.SecretClientImpl - Retrieving secret - COSMOSDB-KEY
06:54:34.702 [ForkJoinPool.commonPool-worker-19] INFO c.a.identity.ClientSecretCredential - Azure Identity => getToken() result for scopes [https://vault.azure.net/.default]: SUCCESS
06:54:34.703 [ForkJoinPool.commonPool-worker-19] INFO c.a.c.i.AccessTokenCache - Acquired a new access token.
06:54:35.074 [reactor-http-nio-3] DEBUG c.a.s.k.s.i.SecretClientImpl - Retrieved secret - COSMOSDB-KEY
06:54:35.075 [main] DEBUG c.a.s.k.s.i.SecretClientImpl - Retrieving secret - COSMOSDB-KEY
06:54:35.117 [reactor-http-nio-3] DEBUG c.a.s.k.s.i.SecretClientImpl - Retrieved secret - COSMOSDB-KEY
06:54:35.118 [main] DEBUG c.a.s.k.s.i.SecretClientImpl - Retrieving secret - COSMOSDB-KEY
06:54:35.163 [reactor-http-nio-3] DEBUG c.a.s.k.s.i.SecretClientImpl - Retrieved secret - COSMOSDB-KEY
06:54:35.167 [main] DEBUG c.a.s.c.c.i.AppConfigurationPropertySourceLocator - PropertySource context.
06:54:35.168 [main] INFO o.s.c.b.c.PropertySourceBootstrapConfiguration - Located property source: [BootstrapPropertySource {name='bootstrapProperties-/application/https://XXXX.azconfig.io/'}]
06:54:35.172 [main] INFO s.convert.ConvertSampleApplication - No active profile set, falling back to 1 default profile: "default"
06:54:35.427 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data cosmos repositories in DEFAULT mode.
06:54:35.456 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 26 ms. Found 1 cosmos repository interfaces.
06:54:35.460 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data cosmos repositories in DEFAULT mode.
06:54:35.463 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 1 ms. Found 0 cosmos repository interfaces.
06:54:35.569 [main] INFO o.s.cloud.context.scope.GenericScope - BeanFactory id=b48292a7-079a-3994-95fb-17b68fe4fd13
06:54:35.659 [main] DEBUG c.a.identity.EnvironmentCredential - Azure Identity => Found the following environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
06:54:35.659 [main] INFO c.a.identity.EnvironmentCredential - Azure Identity => EnvironmentCredential invoking ClientSecretCredential
06:54:35.662 [main] DEBUG c.a.i.ManagedIdentityCredential - Azure Identity => Found the following environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
06:54:35.663 [main] DEBUG c.a.i.SharedTokenCacheCredential - Azure Identity => Found the following environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
06:54:35.700 [main] DEBUG c.a.s.c.c.i.c.AzureHttpProxyOptionsConverter - Proxy hostname or port is not set.
06:54:35.701 [main] DEBUG c.a.s.c.c.i.f.AbstractAzureHttpClientBuilderFactory - No HTTP proxy properties available.
06:54:35.701 [main] DEBUG c.a.s.c.c.i.f.AbstractAzureServiceClientBuilderFactory - No authentication credential configured for class ClientSecretCredentialBuilder.
06:54:35.702 [main] INFO c.a.s.c.c.i.f.AbstractAzureServiceClientBuilderFactory - Will configure the default credential of type DefaultAzureCredential for class com.azure.identity.ClientSecretCredentialBuilder.
06:54:35.706 [main] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosClientBuilderAccessor...
06:54:35.709 [main] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting DirectConnectionConfigAccessor...
06:54:35.712 [main] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosClientTelemetryConfigAccessor...
06:54:35.713 [main] WARN c.a.s.c.s.i.c.CosmosClientBuilderFactory - Configuration instance is not supported to configure in CosmosClientBuilder
06:54:35.713 [main] DEBUG c.a.s.c.s.i.c.CosmosClientBuilderFactory - CosmosClientBuilderFactory does not support common defined retry options
06:54:35.713 [main] DEBUG c.a.s.c.c.i.c.AzureHttpProxyOptionsConverter - Proxy hostname or port is not set.
06:54:35.713 [main] DEBUG c.a.s.c.s.i.c.CosmosClientBuilderFactory - No proxy properties available.
06:54:35.720 [main] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosAsyncClientAccessor...
06:54:35.743 [main] INFO c.a.c.i.RxDocumentClientImpl - Initializing DocumentClient [1] with serviceEndpoint [https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/], connectionPolicy [ConnectionPolicy{httpNetworkRequestTimeout=PT1M, tcpNetworkRequestTimeout=PT5S, connectionMode=GATEWAY, maxConnectionPoo
lSize=1000, idleHttpConnectionTimeout=PT1M, idleTcpConnectionTimeout=PT0S, userAgentSuffix='az-sd-cos/@project.version@az-sp-cos/4.5.0', throttlingRetryOptions=RetryOptions{maxRetryAttemptsOnThrottledRequests=9, maxRetryWaitTime=PT30S}, endpointDiscoveryEnabled=true, preferredRegions=null, multipleWriteRegionsE
nabled=true, proxyType=null, inetSocketProxyAddress=null, readRequestsFallbackEnabled=true, connectTimeout=PT5S, idleTcpEndpointTimeout=PT1H, maxConnectionsPerEndpoint=130, maxRequestsPerConnection=30, tcpConnectionEndpointRediscoveryEnabled=true}], consistencyLevel [null], directModeProtocol [Tcp]
06:54:35.778 [main] DEBUG c.a.c.i.GlobalEndpointManager - registering a refresh in [300000] ms
06:54:35.788 [cosmos-parallel-1] DEBUG c.a.c.i.GlobalEndpointManager - startRefreshLocationTimerAsync() - Invoking refresh, I was registered on [2023-02-01T06:54:35.778909500]
06:54:35.789 [cosmos-parallel-1] INFO c.a.c.i.RxDocumentClientImpl - Getting database account endpoint from https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/
06:54:35.815 [cosmos-parallel-1] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosDiagnosticsAccessor...
06:54:36.038 [reactor-http-nio-4] DEBUG c.a.c.i.GlobalEndpointManager - account retrieved: {"_self":"","id":"my-cosmos-db-XYCDCDCD-eastus","_rid":"my-cosmos-db-XYCDCDCD-eastus.documents.azure.com","media":"//media/","addresses":"//addresses/","_dbs":"//dbs/","writableLocations":[{"name":"East US","databaseAccount
Endpoint":"https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/"}],"readableLocations":[{"name":"East US","databaseAccountEndpoint":"https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/"}],"enableMultipleWriteLocations":false,"userReplicationPolicy":{"asyncReplication":false,"minReplicaSetSize":
3,"maxReplicasetSize":4},"userConsistencyPolicy":{"defaultConsistencyLevel":"Session"},"systemReplicationPolicy":{"minReplicaSetSize":3,"maxReplicasetSize":4},"readPolicy":{"primaryReadCoefficient":1,"secondaryReadCoefficient":1},"queryEngineConfiguration":"{\"allowNewKeywords\":true,\"maxJoinsPerSqlQuery\":10,
\"maxQueryRequestTimeoutFraction\":0.9,\"maxSqlQueryInputLength\":524288,\"maxUdfRefPerSqlQuery\":10,\"queryMaxInMemorySortDocumentCount\":-500,\"spatialMaxGeometryPointCount\":256,\"sqlAllowNonFiniteNumbers\":false,\"sqlDisableOptimizationFlags\":0,\"enableSpatialIndexing\":true,\"maxInExpressionItemsCount\":2
147483647,\"maxLogicalAndPerSqlQuery\":2147483647,\"maxLogicalOrPerSqlQuery\":2147483647,\"maxSpatialQueryCells\":2147483647,\"sqlAllowAggregateFunctions\":true,\"sqlAllowGroupByClause\":true,\"sqlAllowLike\":true,\"sqlAllowSubQuery\":true,\"sqlAllowScalarSubQuery\":true,\"sqlAllowTop\":true}"}
06:54:36.042 [reactor-http-nio-4] DEBUG c.a.c.i.GlobalEndpointManager - db account retrieved
06:54:36.042 [reactor-http-nio-4] DEBUG c.a.c.i.GlobalEndpointManager - refreshLocationPrivateAsync() refreshing locations
06:54:36.044 [reactor-http-nio-4] DEBUG c.a.c.i.routing.LocationCache - updating location cache ..., current readLocations [[https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/]], current writeLocations [[https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/]]
06:54:36.045 [reactor-http-nio-4] DEBUG c.a.c.i.routing.LocationCache - updating location cache finished, new readLocations [[https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/]], new writeLocations [[https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/]]
06:54:36.045 [reactor-http-nio-4] DEBUG c.a.c.i.routing.LocationCache - getWriteEndpoints [[https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/]]
06:54:36.045 [reactor-http-nio-4] DEBUG c.a.c.i.routing.LocationCache - shouldRefreshEndpoints: false, [https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/] is available for Write
06:54:36.046 [reactor-http-nio-4] DEBUG c.a.c.i.GlobalEndpointManager - shouldRefreshEndpoints: true
06:54:36.046 [reactor-http-nio-4] DEBUG c.a.c.i.GlobalEndpointManager - registering a refresh in [300000] ms
06:54:36.059 [reactor-http-nio-5] INFO c.a.c.i.c.ClientTelemetry - Client is not on azure vm
06:54:36.061 [reactor-http-nio-5] DEBUG c.a.c.i.c.ClientTelemetry - Unable to get azure vm metadata
io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: no further information: /169.254.169.254:80
Caused by: java.net.SocketException: Network is unreachable: no further information
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
06:54:36.150 [main] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosAsyncDatabaseAccessor...
06:54:36.153 [main] DEBUG c.a.c.i.RxDocumentClientImpl - Reading a Database. databaseLink: [/dbs/my-cosmos-db-XYCDCDCD]
06:54:36.191 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosContainerPropertiesAccessor...
06:54:36.195 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Initializing CosmosQueryRequestOptionsAccessor...
06:54:36.197 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosClientAccessor...
06:54:36.197 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosClientAccessor already initialized!
06:54:36.198 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosAsyncClientEncryptionKeyAccessor...
06:54:36.198 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosAsyncClientEncryptionKeyAccessor already initialized!
06:54:36.200 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosAsyncContainerAccessor...
06:54:36.200 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosAsyncDatabaseAccessor already initialized!
06:54:36.200 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosClientBuilderAccessor already initialized!
06:54:36.200 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosDiagnosticsAccessor already initialized!
06:54:36.202 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosExceptionAccessor...
06:54:36.202 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosExceptionAccessor already initialized!
06:54:36.202 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - DirectConnectionConfigAccessor already initialized!
06:54:36.203 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosAsyncClientAccessor already initialized!
06:54:36.204 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosBatchAccessor...
06:54:36.204 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosBatchAccessor already initialized!
06:54:36.205 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosBatchOperationResultAccessor...
06:54:36.206 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosBatchOperationResultAccessor already initialized!
06:54:36.207 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosBatchRequestOptionsAccessor...
06:54:36.207 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosBatchRequestOptionsAccessor already initialized!
06:54:36.208 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosBatchResponseAccessor...
06:54:36.208 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosBatchResponseAccessor already initialized!
06:54:36.209 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosBulkExecutionOptionsAccessor...
06:54:36.209 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosBulkExecutionOptionsAccessor already initialized!
06:54:36.210 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosBulkExecutionThresholdsStateAccessor...
06:54:36.210 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosBulkExecutionThresholdsStateAccessor already initialized!
06:54:36.212 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosBulkItemResponseAccessor...
06:54:36.212 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosBulkItemResponseAccessor already initialized!
06:54:36.212 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosChangeFeedRequestOptionsAccessor...
06:54:36.213 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosChangeFeedRequestOptionsAccessor already initialized!
06:54:36.213 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosContainerPropertiesAccessor already initialized!
06:54:36.213 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosItemRequestOptionsAccessor...
06:54:36.213 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosItemRequestOptionsAccessor already initialized!
06:54:36.215 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosItemResponseBuilderAccessor...
06:54:36.215 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosItemResponseBuilderAccessor already initialized!
06:54:36.216 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosPatchOperationsAccessor...
06:54:36.216 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosPatchOperationsAccessor already initialized!
06:54:36.217 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosQueryRequestOptionsAccessor...
06:54:36.217 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosQueryRequestOptionsAccessor already initialized!
06:54:36.218 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting FeedResponseAccessor...
06:54:36.218 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - FeedResponseAccessor already initialized!
06:54:36.218 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting PartitionKeyAccessor...
06:54:36.219 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - PartitionKeyAccessor already initialized!
06:54:36.219 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosClientTelemetryConfigAccessor already initialized!
06:54:36.220 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - Setting CosmosPageFluxAccessor...
06:54:36.220 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosPageFluxAccessor already initialized!
06:54:36.220 [parallel-4] DEBUG c.a.c.i.ImplementationBridgeHelpers - CosmosAsyncContainerAccessor already initialized!
06:54:36.221 [parallel-4] DEBUG c.a.c.i.RxDocumentClientImpl - Reading a Collection. collectionLink: [/dbs/my-cosmos-db-XYCDCDCD/colls/mycollection]
06:54:36.269 [main] DEBUG c.a.c.i.RxDocumentClientImpl - Reading a Collection. collectionLink: [/dbs/my-cosmos-db-XYCDCDCD/colls/mycollection]
06:54:36.355 [main] DEBUG c.a.c.i.SqlQuerySpecLogger - SELECT * FROM ROOT r
06:54:36.363 [main] DEBUG c.a.c.i.caches.AsyncCache - cache[dbs/my-cosmos-db-XYCDCDCD/colls/mycollection] doesn't exist, computing new value
06:54:36.364 [main] DEBUG c.a.c.i.caches.AsyncLazy - constructor
06:54:36.364 [main] DEBUG c.a.c.i.caches.AsyncLazy - using Function<Mono<TValue>> com.azure.cosmos.implementation.caches.RxCollectionCache$$Lambda$1138/0x0000000800773040@4eb63dc8
06:54:36.397 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - set cache[PdsuAPHAgC4=]={"id":"mycollection","indexingPolicy":{"indexingMode":"consistent","automatic":true,"includedPaths":[{"path":"/*"}],"excludedPaths":[{"path":"/\"_etag\"/?"}]},"partitionKey":{"paths":["/lastName"],"kind":"Hash"},"default
Ttl":-1,"uniqueKeyPolicy":{"uniqueKeys":[]},"conflictResolutionPolicy":{"mode":"LastWriterWins","conflictResolutionPath":"/_ts","conflictResolutionProcedure":""},"geospatialConfig":{"type":"Geography"},"_rid":"PdsuAPHAgC4=","_ts":1674650333,"_self":"dbs/PdsuAA==/colls/PdsuAPHAgC4=/","_etag":"\"00008b09-0000-010
0-0000-63d122dd0000\"","_docs":"docs/","_sprocs":"sprocs/","_triggers":"triggers/","_udfs":"udfs/","_conflicts":"conflicts/"}
06:54:36.402 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - cache[dbs/my-cosmos-db-XYCDCDCD/colls/mycollection] exists
06:54:36.404 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - Returning cache[dbs/my-cosmos-db-XYCDCDCD/colls/mycollection] as it is different from obsoleteValue
06:54:36.540 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCacheNonBlocking - cache[PdsuAPHAgC4=] doesn't exist, computing new value
06:54:36.545 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - cache[PdsuAPHAgC4=] exists
06:54:36.546 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - Returning cache[PdsuAPHAgC4=] as it is different from obsoleteValue
06:54:36.584 [reactor-http-nio-4] DEBUG c.a.c.implementation.query.Fetcher - Fetcher state updated: isChangeFeed = false, continuation token = null, max item count = -1, should fetch more = false, Context: n/a
06:54:36.586 [reactor-http-nio-4] DEBUG c.a.c.implementation.query.Paginator - No more results, Context: n/a
06:54:36.597 [reactor-http-nio-4] DEBUG c.a.c.i.q.ParallelDocumentQueryExecutionContext - ParallelQuery: flux mergeSequential concurrency 1, prefetch 16, Context: n/a
06:54:36.603 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - cache[PdsuAPHAgC4=] exists
06:54:36.603 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - Returning cache[PdsuAPHAgC4=] as it is different from obsoleteValue
06:54:36.604 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCacheNonBlocking - cache[PdsuAPHAgC4=] exists
06:54:36.605 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - cache[PdsuAPHAgC4=] exists
06:54:36.605 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - Returning cache[PdsuAPHAgC4=] as it is different from obsoleteValue
06:54:36.606 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCacheNonBlocking - cache[PdsuAPHAgC4=] exists
06:54:36.606 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - cache[PdsuAPHAgC4=] exists
06:54:36.607 [reactor-http-nio-4] DEBUG c.a.c.i.caches.AsyncCache - Returning cache[PdsuAPHAgC4=] as it is different from obsoleteValue
06:54:36.654 [reactor-http-nio-4] DEBUG c.a.c.implementation.query.Fetcher - Fetcher state updated: isChangeFeed = false, continuation token = null, max item count = 100, should fetch more = false, Context: n/a
06:54:36.655 [reactor-http-nio-4] DEBUG c.a.c.implementation.query.Paginator - No more results, Context: n/a
Can the same application work if the spring.cloud.azure.cosmos.*
are configured in the application.properties or bootstrap.properties?
if I take the initialSample (without AppConfiguration) and put my info in application.properties, it works fine
$ mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] --< com.azure.spring:azure-spring-cloud-appconfiguration-config-convert-sample-initial >--
[INFO] Building Convert Cosmos DB Application Using App Configuration and Key Vault Initial 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.7.8:run (default-cli) > test-compile @ azure-spring-cloud-appconfiguration-config-convert-sample-initial >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ azure-spring-cloud-appconfiguration-config-convert-sample-initial ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ azure-spring-cloud-appconfiguration-config-convert-sample-initial ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ azure-spring-cloud-appconfiguration-config-convert-sample-initial ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\to-delete\azure-spring-boot-samples\appconfiguration\azure-spring-cloud-appconfiguration-config\azure-spring-cloud-appconfiguration-config-convert-sample\azure-spring-cloud-appconfiguration-config-convert-sample-initial\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ azure-spring-cloud-appconfiguration-config-convert-sample-initial ---
[INFO] No sources to compile
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.7.8:run (default-cli) < test-compile @ azure-spring-cloud-appconfiguration-config-convert-sample-initial <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.7.8:run (default-cli) @ azure-spring-cloud-appconfiguration-config-convert-sample-initial ---
[INFO] Attaching agents: []
IN THE MAIN!!!!!!!!!!!!!!!
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.8)
2023-02-01 10:12:23.094 INFO 34288 --- [ main] sample.convert.ConvertSampleApplication : Starting ConvertSampleApplication using Java 11.0.15 on BID01795 with PID 34288 (C:\to-delete\azure-spring-boot-samples\appconfiguration\azure-spring-cloud-appconfiguration-config\azure-spring-cloud-appconfiguration-config-convert-sample\azure-spring-cloud-appconfiguration-config-convert-sample-initial\target\classes started by sd003526 in C:\to-delete\azure-spring-boot-samples\appconfiguration\azure-spring-cloud-appconfiguration-config\azure-spring-cloud-appconfiguration-config-convert-sample\azure-spring-cloud-appconfiguration-config-convert-sample-initial)
2023-02-01 10:12:23.096 INFO 34288 --- [ main] sample.convert.ConvertSampleApplication : No active profile set, falling back to 1 default profile: "default"
2023-02-01 10:12:23.376 INFO 34288 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data cosmos repositories in DEFAULT mode.
2023-02-01 10:12:23.406 INFO 34288 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 27 ms. Found 1 cosmos repository interfaces.
2023-02-01 10:12:23.409 INFO 34288 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data cosmos repositories in DEFAULT mode.
2023-02-01 10:12:23.411 INFO 34288 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1 ms. Found 0 cosmos repository interfaces.
2023-02-01 10:12:23.570 INFO 34288 --- [ main] c.a.c.i.jackson.JacksonVersion : Package versions: jackson-core=2.13.4, jackson-databind=2.13.4-2, jackson-dataformat-xml=2.13.4, jackson-datatype-jsr310=2.13.4, azure-core=1.34.0, Troubleshooting version conflicts: https://aka.ms/azsdk/java/dependency/troubleshoot
2023-02-01 10:12:23.632 INFO 34288 --- [ main] AbstractAzureServiceClientBuilderFactory : Will configure the default credential of type DefaultAzureCredential for class com.azure.identity.DefaultAzureCredentialBuilder.
2023-02-01 10:12:23.940 WARN 34288 --- [ main] c.a.s.c.s.i.c.CosmosClientBuilderFactory : Configuration instance is not supported to configure in CosmosClientBuilder
2023-02-01 10:12:23.972 INFO 34288 --- [ main] c.a.c.i.RxDocumentClientImpl : Initializing DocumentClient [1] with serviceEndpoint [https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/], connectionPolicy [ConnectionPolicy{httpNetworkRequestTimeout=PT1M, tcpNetworkRequestTimeout=PT5S, connectionMode=DIRECT, maxConnectionPoolSize=1000, idleHttpConnectionTimeout=PT1M, idleTcpConnectionTimeout=PT0S, userAgentSuffix='az-sd-cos/@project.version@az-sp-cos/4.5.0', throttlingRetryOptions=RetryOptions{maxRetryAttemptsOnThrottledRequests=9, maxRetryWaitTime=PT30S}, endpointDiscoveryEnabled=true, preferredRegions=null, multipleWriteRegionsEnabled=true, proxyType=null, inetSocketProxyAddress=null, readRequestsFallbackEnabled=true, connectTimeout=PT5S, idleTcpEndpointTimeout=PT1H, maxConnectionsPerEndpoint=130, maxRequestsPerConnection=30, tcpConnectionEndpointRediscoveryEnabled=true}], consistencyLevel [null], directModeProtocol [Tcp]
2023-02-01 10:12:24.129 INFO 34288 --- [smos-parallel-1] c.a.c.i.RxDocumentClientImpl : Getting database account endpoint from https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/
2023-02-01 10:12:24.811 INFO 34288 --- [ctor-http-nio-2] c.a.c.i.clienttelemetry.ClientTelemetry : Client is not on azure vm
2023-02-01 10:12:24.813 INFO 34288 --- [ main] c.a.c.i.d.RntbdTransportClient : Using default Direct TCP options: azure.cosmos.directTcp.defaultOptions
2023-02-01 10:12:24.833 INFO 34288 --- [ main] Endpoint$RntbdEndpointMonitoringProvider : Starting RntbdClientChannelPoolMonitoringProvider ...
2023-02-01 10:12:26.850 INFO 34288 --- [ main] c.a.c.i.RxDocumentClientImpl : Initializing DocumentClient [2] with serviceEndpoint [https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/], connectionPolicy [ConnectionPolicy{httpNetworkRequestTimeout=PT1M, tcpNetworkRequestTimeout=PT5S, connectionMode=DIRECT, maxConnectionPoolSize=1000, idleHttpConnectionTimeout=PT1M, idleTcpConnectionTimeout=PT0S, userAgentSuffix='az-sd-cos/@project.version@az-sp-cos/4.5.0', throttlingRetryOptions=RetryOptions{maxRetryAttemptsOnThrottledRequests=9, maxRetryWaitTime=PT30S}, endpointDiscoveryEnabled=true, preferredRegions=null, multipleWriteRegionsEnabled=true, proxyType=null, inetSocketProxyAddress=null, readRequestsFallbackEnabled=true, connectTimeout=PT5S, idleTcpEndpointTimeout=PT1H, maxConnectionsPerEndpoint=130, maxRequestsPerConnection=30, tcpConnectionEndpointRediscoveryEnabled=true}], consistencyLevel [null], directModeProtocol [Tcp]
2023-02-01 10:12:26.852 INFO 34288 --- [smos-parallel-5] c.a.c.i.RxDocumentClientImpl : Getting database account endpoint from https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/
2023-02-01 10:12:27.003 INFO 34288 --- [ main] Endpoint$RntbdEndpointMonitoringProvider : Starting RntbdClientChannelPoolMonitoringProvider ...
2023-02-01 10:12:27.005 INFO 34288 --- [ main] c.a.c.i.RxDocumentClientImpl : Initializing DocumentClient [3] with serviceEndpoint [https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/], connectionPolicy [ConnectionPolicy{httpNetworkRequestTimeout=PT1M, tcpNetworkRequestTimeout=PT5S, connectionMode=DIRECT, maxConnectionPoolSize=1000, idleHttpConnectionTimeout=PT1M, idleTcpConnectionTimeout=PT0S, userAgentSuffix='az-sd-cos/@project.version@az-sp-cos/4.5.0', throttlingRetryOptions=RetryOptions{maxRetryAttemptsOnThrottledRequests=9, maxRetryWaitTime=PT30S}, endpointDiscoveryEnabled=true, preferredRegions=null, multipleWriteRegionsEnabled=true, proxyType=null, inetSocketProxyAddress=null, readRequestsFallbackEnabled=true, connectTimeout=PT5S, idleTcpEndpointTimeout=PT1H, maxConnectionsPerEndpoint=130, maxRequestsPerConnection=30, tcpConnectionEndpointRediscoveryEnabled=true}], consistencyLevel [null], directModeProtocol [Tcp]
2023-02-01 10:12:27.006 INFO 34288 --- [smos-parallel-8] c.a.c.i.RxDocumentClientImpl : Getting database account endpoint from https://my-cosmos-db-XYCDCDCD-eastus.documents.azure.com:443/
2023-02-01 10:12:27.013 INFO 34288 --- [ctor-http-nio-4] c.a.c.i.clienttelemetry.ClientTelemetry : Client is not on azure vm
2023-02-01 10:12:27.144 INFO 34288 --- [ctor-http-nio-6] c.a.c.i.clienttelemetry.ClientTelemetry : Client is not on azure vm
2023-02-01 10:12:27.155 INFO 34288 --- [ main] Endpoint$RntbdEndpointMonitoringProvider : Starting RntbdClientChannelPoolMonitoringProvider ...
2023-02-01 10:12:27.206 INFO 34288 --- [ main] sample.convert.ConvertSampleApplication : Started ConvertSampleApplication in 4.335 seconds (JVM running for 4.652)
IN THE RUN!!!!!!!!!!!!!!!!!!2023-02-01 10:12:28.503 INFO 34288 --- [ main] sample.convert.ConvertSampleApplication : findOne in User collection get result: testFirstName
Could you try to run the complete sample (the one with App Configuration), and also configure the spring.cloud.azure.cosmos
properties, to see whether it can work?
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)
{
"/application/azure.cosmos.database": "my-cosmos-db-XXXX",
"/application/azure.cosmos.key": {
"uri": "https://myvaultname-XXX.vault.azure.net/secrets/COSMOSDB-KEY"
},
"/application/azure.cosmos.uri": "https://my-cosmos-db-XXX-eastus.documents.azure.com:443/",
"/application/db.url": "xxxurl",
"/application/spring.azure.cosmos.database": "my-cosmos-db-XXX",
"/application/spring.azure.cosmos.endpoint": "https://my-cosmos-db-XXXX-eastus.documents.azure.com:443/",
"/application/spring.azure.cosmos.key": {
"uri": "https://myvaultname-XXXX.vault.azure.net/secrets/COSMOSDB-KEY"
},
"/application/spring.azure.cosmos.uri": "https://my-cosmos-db-XXXX-eastus.documents.azure.com:443/",
"/application/spring.cloud.azure.cosmos.database": "my-cosmos-db-XXXX",
"/application/spring.cloud.azure.cosmos.endpoint": "https://my-cosmos-db-XXXX-eastus.documents.azure.com:443/",
"/application/spring.cloud.azure.cosmos.key": {
"uri": "https://myvaultname-XXXX.vault.azure.net/secrets/COSMOSDB-KEY"
},
"/application/url": "maudit-beau-url"
}
If you move the code in the @PostConstruct
to the run
method, then it would resolve the issue.
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.
- Include Terraform script to create the resources
- Include source code
- Terraform output will update bootstrap.properties file and generate environment variable script
terraform-appconfig-cosmos.zip
With that we should have the exact same setup.
What's the issue right now? I checked the demo, the spring.cloud.azure.cosmos.database
property is missing.
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.