diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/appconfiguration/AzureAppConfigurationAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/appconfiguration/AzureAppConfigurationAutoConfiguration.java index a2ad21dd3aca4..6601dd7e2bcaf 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/appconfiguration/AzureAppConfigurationAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/appconfiguration/AzureAppConfigurationAutoConfiguration.java @@ -9,6 +9,7 @@ import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.service.appconfiguration.ConfigurationClientBuilderFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -49,6 +50,7 @@ public ConfigurationAsyncClient azureConfigurationAsyncClient(ConfigurationClien @Bean @ConditionalOnMissingBean public ConfigurationClientBuilder configurationClientBuilder(ConfigurationClientBuilderFactory factory) { + factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_APP_CONFIG); return factory.build(); } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubClientBuilderConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubClientBuilderConfiguration.java index 09185385818ab..67e7823f3ca10 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubClientBuilderConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubClientBuilderConfiguration.java @@ -6,7 +6,7 @@ import com.azure.messaging.eventhubs.EventHubClientBuilder; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.ConnectionStringProvider; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; @@ -39,7 +39,7 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactory(AzureEventHubPr final EventHubClientBuilderFactory builderFactory = new EventHubClientBuilderFactory(properties); builderFactory.setConnectionStringProvider(connectionStringProviders.getIfAvailable()); - builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_EVENT_HUB); + builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB); return builderFactory; } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubConsumerClientConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubConsumerClientConfiguration.java index bc2539a4d72d5..d6a03d358e944 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubConsumerClientConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubConsumerClientConfiguration.java @@ -9,7 +9,7 @@ import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty; import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; import com.azure.spring.service.core.PropertyMapper; @@ -85,7 +85,7 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactoryForConsumer() { builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUB, this.consumerProperties.getConnectionString())); - builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_EVENT_HUB); + builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB); return builderFactory; } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubProducerClientConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubProducerClientConfiguration.java index 8f9e46823c248..8906adfd74118 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubProducerClientConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhubs/AzureEventHubProducerClientConfiguration.java @@ -9,7 +9,7 @@ import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty; import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; import com.azure.spring.service.eventhubs.factory.EventHubClientBuilderFactory; @@ -67,7 +67,7 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactoryForProducer() { builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUB, this.producerProperties.getConnectionString())); - builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_EVENT_HUB); + builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB); return builderFactory; } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/PremiumServiceBusJmsAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/PremiumServiceBusJmsAutoConfiguration.java index 0bf3990a2352a..19981f097fc39 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/PremiumServiceBusJmsAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/PremiumServiceBusJmsAutoConfiguration.java @@ -15,8 +15,8 @@ import javax.jms.ConnectionFactory; -import static com.azure.spring.core.ApplicationId.AZURE_SPRING_SERVICE_BUS; -import static com.azure.spring.core.ApplicationId.VERSION; +import static com.azure.spring.core.AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS; +import static com.azure.spring.core.AzureSpringIdentifier.VERSION; /** * Automatic configuration class of ServiceBusJMS for Premium Service Bus diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/certificates/AzureKeyVaultCertificateAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/certificates/AzureKeyVaultCertificateAutoConfiguration.java index a4bada364ef77..6360cb5765b69 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/certificates/AzureKeyVaultCertificateAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/certificates/AzureKeyVaultCertificateAutoConfiguration.java @@ -50,6 +50,8 @@ public CertificateAsyncClient azureKeyVaultCertificateAsyncClient(CertificateCli @Bean @ConditionalOnMissingBean public CertificateClientBuilder certificateClientBuilder(CertificateClientBuilderFactory factory) { + // TODO (xiada): how to distinguish this from kv secrets? +// factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_KEY_VAULT); return factory.build(); } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/secrets/AzureKeyVaultSecretAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/secrets/AzureKeyVaultSecretAutoConfiguration.java index d2a426ef8dccf..fbb5bc47de38f 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/secrets/AzureKeyVaultSecretAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/keyvault/secrets/AzureKeyVaultSecretAutoConfiguration.java @@ -9,6 +9,7 @@ import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.service.keyvault.secrets.SecretClientBuilderFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -50,6 +51,7 @@ public SecretAsyncClient azureKeyVaultSecretAsyncClient(SecretClientBuilder buil @Bean @ConditionalOnMissingBean public SecretClientBuilder secretClientBuilder(SecretClientBuilderFactory factory) { + factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_KEY_VAULT); return factory.build(); } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusClientBuilderConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusClientBuilderConfiguration.java index 3e329a94cc231..9ca33e3feac38 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusClientBuilderConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusClientBuilderConfiguration.java @@ -6,7 +6,7 @@ import com.azure.messaging.servicebus.ServiceBusClientBuilder; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.ConnectionStringProvider; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; @@ -36,10 +36,10 @@ class AzureServiceBusClientBuilderConfiguration { public ServiceBusClientBuilderFactory serviceBusClientBuilderFactory( ObjectProvider> connectionStringProviders) { - final ServiceBusClientBuilderFactory builderFactory = new ServiceBusClientBuilderFactory(this.serviceBusProperties); - builderFactory.setConnectionStringProvider(connectionStringProviders.getIfAvailable()); - builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS); - return builderFactory; + final ServiceBusClientBuilderFactory factory = new ServiceBusClientBuilderFactory(this.serviceBusProperties); + factory.setConnectionStringProvider(connectionStringProviders.getIfAvailable()); + factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS); + return factory; } @Bean diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusConsumerClientConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusConsumerClientConfiguration.java index 1917b7eae175a..409d8b1046607 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusConsumerClientConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusConsumerClientConfiguration.java @@ -13,7 +13,7 @@ import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty; import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; import com.azure.spring.service.servicebus.ServiceBusClientBuilderFactory; @@ -70,7 +70,7 @@ public ServiceBusClientBuilderFactory serviceBusClientBuilderFactoryForConsumer( builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.SERVICE_BUS, this.consumerProperties.getConnectionString())); - builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS); + builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS); return builderFactory; } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProcessorConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProcessorConfiguration.java index e0fc6a38904b5..3c0b611ea8d35 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProcessorConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProcessorConfiguration.java @@ -8,7 +8,7 @@ import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty; import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; import com.azure.spring.service.servicebus.ServiceBusClientBuilderFactory; @@ -67,7 +67,7 @@ public ServiceBusClientBuilderFactory serviceBusClientBuilderFactoryForProcessor final ServiceBusClientBuilderFactory builderFactory = new ServiceBusClientBuilderFactory(this.processorProperties); builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.SERVICE_BUS, this.processorProperties.getConnectionString())); - builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS); + builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS); return builderFactory; } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProducerClientConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProducerClientConfiguration.java index 9a8b30d6d0c96..7c511fc3ce5f2 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProducerClientConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusProducerClientConfiguration.java @@ -11,7 +11,7 @@ import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty; import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; import com.azure.spring.service.servicebus.ServiceBusClientBuilderFactory; @@ -75,7 +75,7 @@ public ServiceBusClientBuilderFactory serviceBusClientBuilderFactoryForProducer( builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.SERVICE_BUS, this.producerProperties.getConnectionString())); - builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS); + builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS); return builderFactory; } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/blob/AzureStorageBlobAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/blob/AzureStorageBlobAutoConfiguration.java index b067d61042dde..7c2014b1f5c56 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/blob/AzureStorageBlobAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/blob/AzureStorageBlobAutoConfiguration.java @@ -6,6 +6,7 @@ import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.service.storage.blob.BlobServiceClientBuilderFactory; import com.azure.storage.blob.BlobAsyncClient; import com.azure.storage.blob.BlobClient; @@ -95,6 +96,7 @@ public BlobServiceClientBuilderFactory blobServiceClientBuilderFactory(AzureStor @ConditionalOnMissingBean public BlobServiceClientBuilder blobServiceClientBuilder(@Qualifier(STORAGE_BLOB_CLIENT_BUILDER_FACTORY_BEAN_NAME) BlobServiceClientBuilderFactory factory) { + factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_STORAGE_BLOB); return factory.build(); } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/fileshare/AzureStorageFileShareAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/fileshare/AzureStorageFileShareAutoConfiguration.java index 452ac5b040c3c..3cb88376534dc 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/fileshare/AzureStorageFileShareAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/fileshare/AzureStorageFileShareAutoConfiguration.java @@ -6,6 +6,7 @@ import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.service.storage.fileshare.ShareServiceClientBuilderFactory; import com.azure.storage.file.share.ShareAsyncClient; import com.azure.storage.file.share.ShareClient; @@ -59,6 +60,7 @@ public ShareServiceClientBuilderFactory shareServiceClientBuilderFactory(AzureSt @Bean @ConditionalOnMissingBean public ShareServiceClientBuilder shareServiceClientBuilder(ShareServiceClientBuilderFactory factory) { + factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_STORAGE_FILES); return factory.build(); } diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/queue/AzureStorageQueueAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/queue/AzureStorageQueueAutoConfiguration.java index 4029fa765dd7a..aea9b83028a21 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/queue/AzureStorageQueueAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/storage/queue/AzureStorageQueueAutoConfiguration.java @@ -6,6 +6,7 @@ import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase; import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty; import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties; +import com.azure.spring.core.AzureSpringIdentifier; import com.azure.spring.core.connectionstring.ConnectionStringProvider; import com.azure.spring.core.connectionstring.StaticConnectionStringProvider; import com.azure.spring.core.service.AzureServiceType; @@ -62,6 +63,7 @@ public QueueServiceClientBuilderFactory queueServiceClientBuilderFactory(AzureSt @Bean @ConditionalOnMissingBean public QueueServiceClientBuilder queueServiceClientBuilder(QueueServiceClientBuilderFactory factory) { + factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_STORAGE_QUEUE); return factory.build(); } diff --git a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/ApplicationId.java b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/AzureSpringIdentifier.java similarity index 81% rename from sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/ApplicationId.java rename to sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/AzureSpringIdentifier.java index 8a2b6e6dfb208..de940f661c3c9 100644 --- a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/ApplicationId.java +++ b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/AzureSpringIdentifier.java @@ -12,9 +12,9 @@ import java.util.Properties; /** - * Util class for ApplicationId + * Util class for AzureSpringIdentifier */ -public class ApplicationId { +public class AzureSpringIdentifier { // There is 24 char limitation about the app id. So some abbreviation needs to be applied: // az: for Azure // sp: for Spring @@ -32,17 +32,17 @@ public class ApplicationId { // cos: for Cosmos // aad: for AAD // b2c: for AAD B2C - private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationId.class); + private static final Logger LOGGER = LoggerFactory.getLogger(AzureSpringIdentifier.class); public static final String VERSION = getVersion(); - public static final String AZURE_SPRING_KEY_VAULT = "az-sp-kv/"; - public static final String AZURE_SPRING_SERVICE_BUS = "az-sp-bus/"; - public static final String AZURE_SPRING_STORAGE_BLOB = "az-sp-sb/"; - public static final String AZURE_SPRING_STORAGE_FILES = "az-sp-sf/"; - - public static final String AZURE_SPRING_COSMOS = "az-sp-cosmos"; - public static final String AZURE_SPRING_EVENT_HUB = "az-sc-eh/;"; - public static final String AZURE_SPRING_STORAGE_QUEUE = "az-sp-sq/"; - public static final String AZURE_SPRING_INTEGRATION_STORAGE_QUEUE = "az-si-sq/"; + public static final String AZURE_SPRING_APP_CONFIG = "az-sp-cfg/" + VERSION; + public static final String AZURE_SPRING_EVENT_HUB = "az-sp-eh/" + VERSION; + public static final String AZURE_SPRING_KEY_VAULT = "az-sp-kv/" + VERSION; + public static final String AZURE_SPRING_SERVICE_BUS = "az-sp-bus/" + VERSION; + public static final String AZURE_SPRING_STORAGE_BLOB = "az-sp-sb/" + VERSION; + public static final String AZURE_SPRING_STORAGE_FILES = "az-sp-sf/" + VERSION; + public static final String AZURE_SPRING_COSMOS = "az-sp-cos/" + VERSION; + public static final String AZURE_SPRING_STORAGE_QUEUE = "az-sp-sq/" + VERSION; + public static final String AZURE_SPRING_INTEGRATION_STORAGE_QUEUE = "az-si-sq/" + VERSION; /** * AZURE_SPRING_AAD does not contain VERSION, because AAD server support 2 headers: 1. x-client-SKU; 2. diff --git a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureAmqpClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureAmqpClientBuilderFactory.java index 4f2db41e48422..e3bf0240df961 100644 --- a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureAmqpClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureAmqpClientBuilderFactory.java @@ -60,8 +60,8 @@ protected void configureClientProperties(T builder) { } @Override - protected void configureApplicationId(T builder) { - this.clientOptions.setApplicationId(getApplicationId()); + protected BiConsumer consumeApplicationId() { + return (builder, id) -> this.clientOptions.setApplicationId(id); } @Override @@ -96,6 +96,4 @@ public void setClientOptions(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - - } diff --git a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureHttpClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureHttpClientBuilderFactory.java index 619ba4cc78f94..5ddf0cc10e540 100644 --- a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureHttpClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureHttpClientBuilderFactory.java @@ -92,8 +92,8 @@ protected void configureProxy(T builder) { } @Override - protected void configureApplicationId(T builder) { - this.httpClientOptions.setApplicationId(getApplicationId()); + protected BiConsumer consumeApplicationId() { + return (builder, id) -> this.httpClientOptions.setApplicationId(id); } protected void configureHttpHeaders(T builder) { diff --git a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureServiceClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureServiceClientBuilderFactory.java index 0db46b2ef0cb6..0d08e79a6eded 100644 --- a/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureServiceClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/core/factory/AbstractAzureServiceClientBuilderFactory.java @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -42,14 +43,14 @@ public abstract class AbstractAzureServiceClientBuilderFactory implements Azu protected abstract List> getAuthenticationDescriptors(T builder); - protected abstract void configureApplicationId(T builder); - protected abstract void configureProxy(T builder); protected abstract void configureRetry(T builder); protected abstract void configureService(T builder); + protected abstract BiConsumer consumeApplicationId(); + protected abstract BiConsumer consumeConfiguration(); protected abstract BiConsumer consumeDefaultTokenCredential(); @@ -63,9 +64,12 @@ public abstract class AbstractAzureServiceClientBuilderFactory implements Azu private boolean credentialConfigured = false; /** - * 1. create a builder instance 2. configure builder 2.1 configure azure core level configuration 2.1.1 configure - * http client getHttpClientInstance 2.2 configure service level configuration 3. customize builder 4. return - * builder + *
    + *
  1. Create a builder instance.
  2. + *
  3. Configure Azure core level configuration.
  4. + *
  5. Configure service level configuration.
  6. + *
  7. Customize builder.
  8. + *
* * @return the service client builder */ @@ -87,6 +91,17 @@ protected void configureCore(T builder) { configureDefaultCredential(builder); } + /** + * The application id provided to sdk should be a concatenation of customer-application-id and + * azure-spring-identifier. + * + * @param builder the service client builder + */ + protected void configureApplicationId(T builder) { + String applicationId = getApplicationId() + this.springIdentifier; + consumeApplicationId().accept(builder, applicationId); + } + protected void configureAzureEnvironment(T builder) { AzureProfileAware.Profile profile = getAzureProperties().getProfile(); @@ -163,13 +178,19 @@ private AzureCredentialProvider resolveAzureCredential(AzureProperties azureP return credentialResolvers.resolve(azureProperties); } - protected String getApplicationId() { + private String getApplicationId() { final ClientAware.Client client = getAzureProperties().getClient(); - return this.applicationId != null ? this.applicationId : (client != null ? client.getApplicationId() : null); + return Optional.ofNullable(client) + .map(ClientAware.Client::getApplicationId) + .orElse(""); } - public void setApplicationId(String applicationId) { - this.applicationId = applicationId; + public void setSpringIdentifier(String springIdentifier) { + if (!StringUtils.hasText(springIdentifier)) { + LOGGER.warn("SpringIdentifier is null or empty."); + return; + } + this.springIdentifier = springIdentifier; } public void setDefaultTokenCredential(TokenCredential defaultTokenCredential) { @@ -179,8 +200,4 @@ public void setDefaultTokenCredential(TokenCredential defaultTokenCredential) { public void setConnectionStringProvider(ConnectionStringProvider connectionStringProvider) { this.connectionStringProvider = connectionStringProvider; } - - public void setSpringIdentifier(String springIdentifier) { - this.springIdentifier = springIdentifier; - } } diff --git a/sdk/spring/spring-cloud-azure-core/src/test/java/com/azure/spring/cloud/context/core/ApplicationIdTest.java b/sdk/spring/spring-cloud-azure-core/src/test/java/com/azure/spring/cloud/context/core/ApplicationIdTest.java index f3eb9387e3d9f..2b870791a981e 100644 --- a/sdk/spring/spring-cloud-azure-core/src/test/java/com/azure/spring/cloud/context/core/ApplicationIdTest.java +++ b/sdk/spring/spring-cloud-azure-core/src/test/java/com/azure/spring/cloud/context/core/ApplicationIdTest.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. package com.azure.spring.cloud.context.core; -import com.azure.spring.core.ApplicationId; +import com.azure.spring.core.AzureSpringIdentifier; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -11,7 +11,7 @@ public class ApplicationIdTest { @Test public void testPomVersion() { - Assertions.assertNotNull(ApplicationId.VERSION); - Assertions.assertNotEquals("unknown", ApplicationId.VERSION); + Assertions.assertNotNull(AzureSpringIdentifier.VERSION); + Assertions.assertNotEquals("unknown", AzureSpringIdentifier.VERSION); } } diff --git a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/cosmos/CosmosClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/cosmos/CosmosClientBuilderFactory.java index dd1d5b9a816ef..88c5be5740de2 100644 --- a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/cosmos/CosmosClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/cosmos/CosmosClientBuilderFactory.java @@ -7,7 +7,6 @@ import com.azure.core.util.Configuration; import com.azure.cosmos.ConnectionMode; import com.azure.cosmos.CosmosClientBuilder; -import com.azure.spring.core.ApplicationId; import com.azure.spring.core.credential.descriptor.AuthenticationDescriptor; import com.azure.spring.core.credential.descriptor.KeyAuthenticationDescriptor; import com.azure.spring.core.credential.descriptor.TokenAuthenticationDescriptor; @@ -53,11 +52,6 @@ protected List> getAuthenticationDescriptors(CosmosC ); } - @Override - protected void configureApplicationId(CosmosClientBuilder builder) { - builder.userAgentSuffix(ApplicationId.AZURE_SPRING_COSMOS); - } - @Override protected void configureProxy(CosmosClientBuilder builder) { LOGGER.debug("No configureProxy for CosmosClientBuilder."); @@ -94,6 +88,11 @@ protected void configureService(CosmosClientBuilder builder) { } } + @Override + protected BiConsumer consumeApplicationId() { + return CosmosClientBuilder::userAgentSuffix; + } + @Override protected BiConsumer consumeConfiguration() { LOGGER.warn("Configuration instance is not supported to configure in CosmosClientBuilder"); diff --git a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/eventhubs/factory/EventHubClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/eventhubs/factory/EventHubClientBuilderFactory.java index b2605a65214b9..a66a610a2e2a8 100644 --- a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/eventhubs/factory/EventHubClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/eventhubs/factory/EventHubClientBuilderFactory.java @@ -128,8 +128,4 @@ protected List> getAuthenticationDescriptors(EventHu ); } - @Override - protected String getApplicationId() { - return super.getApplicationId(); - } } diff --git a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/blob/BlobServiceClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/blob/BlobServiceClientBuilderFactory.java index 3cd68535b2a08..090cc2aaf7e50 100644 --- a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/blob/BlobServiceClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/blob/BlobServiceClientBuilderFactory.java @@ -24,9 +24,6 @@ import java.util.List; import java.util.function.BiConsumer; -import static com.azure.spring.core.ApplicationId.AZURE_SPRING_STORAGE_BLOB; -import static com.azure.spring.core.ApplicationId.VERSION; - /** * Storage Blob Service client builder factory, it builds the storage blob client according the configuration context * and blob properties. @@ -102,11 +99,6 @@ protected List> getAuthenticationDescriptors(BlobSer ); } - @Override - protected String getApplicationId() { - return AZURE_SPRING_STORAGE_BLOB + VERSION; - } - @Override protected BiConsumer consumeRequestRetryOptions() { return BlobServiceClientBuilder::retryOptions; diff --git a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/fileshare/ShareServiceClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/fileshare/ShareServiceClientBuilderFactory.java index 361a0e3847f25..a125a33443d47 100644 --- a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/fileshare/ShareServiceClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/fileshare/ShareServiceClientBuilderFactory.java @@ -24,9 +24,6 @@ import java.util.List; import java.util.function.BiConsumer; -import static com.azure.spring.core.ApplicationId.AZURE_SPRING_STORAGE_FILES; -import static com.azure.spring.core.ApplicationId.VERSION; - /** * Storage File Share Service client builder factory, it builds the storage blob client according the configuration * context and blob properties. @@ -102,11 +99,6 @@ protected BiConsumer consumeConnectionString( return ShareServiceClientBuilder::connectionString; } - @Override - protected String getApplicationId() { - return AZURE_SPRING_STORAGE_FILES + VERSION; - } - @Override protected BiConsumer consumeRequestRetryOptions() { return ShareServiceClientBuilder::retryOptions; diff --git a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/queue/QueueServiceClientBuilderFactory.java b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/queue/QueueServiceClientBuilderFactory.java index 46cd5d5a81d8b..eb490296978b4 100644 --- a/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/queue/QueueServiceClientBuilderFactory.java +++ b/sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/service/storage/queue/QueueServiceClientBuilderFactory.java @@ -24,9 +24,6 @@ import java.util.List; import java.util.function.BiConsumer; -import static com.azure.spring.core.ApplicationId.AZURE_SPRING_STORAGE_QUEUE; -import static com.azure.spring.core.ApplicationId.VERSION; - /** * Storage Queue Service client builder factory, it builds the storage blob client according the configuration context * and blob properties. @@ -100,11 +97,6 @@ protected BiConsumer consumeConnectionString( return QueueServiceClientBuilder::connectionString; } - @Override - protected String getApplicationId() { - return AZURE_SPRING_STORAGE_QUEUE + VERSION; - } - private QueueMessageEncoding convertToMessageEncoding(String messageEncoding) { return QueueMessageEncoding.BASE64 .name()