Skip to content

Commit

Permalink
update cosmos nosql connection strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaconsalvi committed Nov 27, 2024
1 parent 5f1e936 commit b4eb39d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
package it.gov.pagopa.rtp.activator.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.azure.cosmos.CosmosClientBuilder;
import com.azure.identity.DefaultAzureCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.spring.data.cosmos.config.AbstractCosmosConfiguration;
import com.azure.spring.data.cosmos.repository.config.EnableReactiveCosmosRepositories;

@Configuration
@EnableReactiveCosmosRepositories("it.gov.pagopa.rtp.activator.repository")
public class CosmosDBConfig extends AbstractCosmosConfiguration {

private CosmosPropertiesConfig cosmosPropertiesConfig;

public CosmosDBConfig(CosmosPropertiesConfig cosmosPropertiesConfig){
this.cosmosPropertiesConfig = cosmosPropertiesConfig;
}

@Override
protected String getDatabaseName() {
return cosmosPropertiesConfig.getDatabase();
}

@Bean
public CosmosClientBuilder getCosmosClientBuilder() {
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
.build();

return new CosmosClientBuilder()
.endpoint(cosmosPropertiesConfig.getUri())
.credential(credential);
}

public class CosmosDBConfig {
}

This file was deleted.

7 changes: 4 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ management.endpoint.health.probes.enabled=true

#repository

azure.cosmos.uri=${COSMOS_ACCOUNT_RTP_ENDPOINT:}
azure.cosmos.key=${AZURE_COSMOS_KEY:}
azure.cosmos.database=${DB_NAME:rtp}
spring.cloud.azure.cosmos.endpoint=${COSMOS_ACCOUNT_RTP_ENDPOINT:}
spring.cloud.azure.cosmos.key=${AZURE_COSMOS_KEY:}
spring.cloud.azure.cosmos.database=${DB_NAME:rtp}
spring.cloud.azure.cosmos.populate-query-metrics=true
activation.base-url=${BASE_URL:http://localhost}

This file was deleted.

This file was deleted.

0 comments on commit b4eb39d

Please sign in to comment.