Skip to content
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

Update retry configuration for Azure SDKs service builder in Spring tier #25104

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ private static TokenCredential credentials() {
public void keyVaultAsPropertySource() {
LOGGER.info("keyVaultAsPropertySource begin.");
try (AppRunner app = new AppRunner(DummyApp.class)) {
app.property("spring.cloud.azure.keyvault.secret.enabled", "false");
app.property("spring.cloud.azure.keyvault.secret.property-source-enabled", "true");
app.property("spring.cloud.azure.keyvault.secret.endpoint", AZURE_KEYVAULT_URI);
app.property("spring.cloud.azure.keyvault.secret.credential.client-id", SPRING_CLIENT_ID);
Expand All @@ -99,7 +98,6 @@ public void keyVaultAsPropertySource() {
public void keyVaultAsPropertySourceWithSpecificKeys() {
LOGGER.info("keyVaultAsPropertySourceWithSpecificKeys begin.");
try (AppRunner app = new AppRunner(DummyApp.class)) {
app.property("spring.cloud.azure.keyvault.secret.enabled", "false");
app.property("spring.cloud.azure.keyvault.secret.property-source-enabled", "true");
app.property("spring.cloud.azure.keyvault.secret.endpoint", AZURE_KEYVAULT_URI);
app.property("spring.cloud.azure.keyvault.secret.credential.client-id", SPRING_CLIENT_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
package com.azure.spring.cloud.autoconfigure.appconfiguration;

import com.azure.data.appconfiguration.ConfigurationServiceVersion;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureHttpConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureHttpCP;
import com.azure.spring.service.appconfiguration.AppConfigurationProperties;

/**
* Properties for Azure App Configuration.
*/
public class AzureAppConfigurationProperties extends AbstractAzureHttpConfigurationProperties
public class AzureAppConfigurationProperties extends AbstractAzureHttpCP
implements AppConfigurationProperties {

public static final String PREFIX = "spring.cloud.azure.appconfiguration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import com.azure.cosmos.GatewayConnectionConfig;
import com.azure.cosmos.ThrottlingRetryOptions;
import com.azure.cosmos.models.CosmosPermissionProperties;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureServiceConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.core.AbstractAzureServiceCP;
import com.azure.spring.core.properties.client.ClientProperties;
import com.azure.spring.service.cosmos.CosmosProperties;
import com.azure.spring.core.properties.proxy.HttpProxyProperties;
import com.azure.spring.service.cosmos.CosmosProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.validation.annotation.Validated;

Expand All @@ -25,13 +25,16 @@
* Configuration properties for Cosmos database, consistency, telemetry, connection, query metrics and diagnostics.
*/
@Validated
public class AzureCosmosProperties extends AbstractAzureServiceConfigurationProperties implements CosmosProperties {
public class AzureCosmosProperties extends AbstractAzureServiceCP implements CosmosProperties {

public static final String PREFIX = "spring.cloud.azure.cosmos";

@NestedConfigurationProperty
private final HttpProxyProperties proxy = new HttpProxyProperties();

@NestedConfigurationProperty
private final ClientProperties client = new ClientProperties();

@NotEmpty
@Pattern(regexp = "http[s]{0,1}://.*.documents.azure.com.*")
private String endpoint;
Expand Down Expand Up @@ -76,7 +79,7 @@ public HttpProxyProperties getProxy() {

@Override
public ClientProperties getClient() {
return new ClientProperties();
return client;
}

public String getEndpoint() {
Expand All @@ -92,7 +95,6 @@ public String getKey() {
return key;
}

@Override
public void setKey(String key) {
this.key = key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

package com.azure.spring.cloud.autoconfigure.eventhubs.properties;

import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureAmqpConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureAmqpCP;
import com.azure.spring.core.connectionstring.implementation.EventHubConnectionString;

/**
* Azure Event Hub related properties.
*/
public abstract class AzureEventHubCommonProperties extends AbstractAzureAmqpConfigurationProperties {
public abstract class AzureEventHubCommonProperties extends AbstractAzureAmqpCP {

protected String domainName = "servicebus.windows.net";
protected String namespace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package com.azure.spring.cloud.autoconfigure.keyvault;

import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureHttpConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureHttpCP;

/**
* Common properties for Azure Key Vault
*/
public class AzureKeyVaultProperties extends AbstractAzureHttpConfigurationProperties {
public class AzureKeyVaultProperties extends AbstractAzureHttpCP {

// TODO (xiada): the default vault url
private String endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringAp
addKeyVaultPropertySource(environment, properties);
}
} else {
logger.debug("Key Vault property source is not enabled");
logger.debug("Key Vault 'propertySourceEnabled' or 'enabled' is not enabled");
}
}

Expand Down Expand Up @@ -170,8 +170,8 @@ private AzureKeyVaultSecretProperties loadProperties(Binder binder) {
* @return true if the key vault is enabled, false otherwise.
*/
private boolean isKeyVaultPropertySourceEnabled(AzureKeyVaultSecretProperties properties) {
return Boolean.TRUE.equals(properties.getPropertySourceEnabled())
|| !properties.getPropertySources().isEmpty();
return (Boolean.TRUE.equals(properties.getPropertySourceEnabled()) || !properties.getPropertySources().isEmpty())
&& Boolean.TRUE.equals(properties.isEnabled());
}

private boolean isKeyVaultClientAvailable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.azure.spring.cloud.autoconfigure.keyvault.secrets;

import com.azure.security.keyvault.secrets.SecretServiceVersion;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureHttpConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureHttpCP;

import java.time.Duration;
import java.util.List;
Expand All @@ -14,7 +14,7 @@
/**
* Configurations to set when Azure Key Vault is used as an external property source.
*/
public class AzureKeyVaultPropertySourceProperties extends AbstractAzureHttpConfigurationProperties {
public class AzureKeyVaultPropertySourceProperties extends AbstractAzureHttpCP {

public static final Duration DEFAULT_REFRESH_INTERVAL = Duration.ofMinutes(30);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.spring.cloud.autoconfigure.properties;

import com.azure.spring.cloud.autoconfigure.properties.core.AbstractAzureServiceCP;
import com.azure.spring.cloud.autoconfigure.properties.core.client.AmqpClientCP;
import com.azure.spring.cloud.autoconfigure.properties.core.proxy.ProxyCP;
import com.azure.spring.cloud.autoconfigure.properties.core.retry.RetryCP;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

/**
*
*/
public abstract class AbstractAzureAmqpCP extends AbstractAzureServiceCP {

@NestedConfigurationProperty
protected final AmqpClientCP client = new AmqpClientCP();

@NestedConfigurationProperty
protected final RetryCP retry = new RetryCP();

@NestedConfigurationProperty
protected final ProxyCP proxy = new ProxyCP();

@Override
public AmqpClientCP getClient() {
return client;
}

@Override
public RetryCP getRetry() {
return retry;
}

@Override
public ProxyCP getProxy() {
return proxy;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.spring.cloud.autoconfigure.properties;

import com.azure.spring.cloud.autoconfigure.properties.core.AbstractAzureServiceCP;
import com.azure.spring.cloud.autoconfigure.properties.core.client.HttpClientCP;
import com.azure.spring.cloud.autoconfigure.properties.core.proxy.HttpProxyCP;
import com.azure.spring.cloud.autoconfigure.properties.core.retry.HttpRetryCP;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

/**
* Configuration properties base class for all Azure Http clients.
*/
public abstract class AbstractAzureHttpCP extends AbstractAzureServiceCP {

@NestedConfigurationProperty
protected final HttpClientCP client = new HttpClientCP();

@NestedConfigurationProperty
protected final HttpProxyCP proxy = new HttpProxyCP();

@NestedConfigurationProperty
protected final HttpRetryCP retry = new HttpRetryCP();

@Override
public HttpClientCP getClient() {
return client;
}

@Override
public HttpProxyCP getProxy() {
return proxy;
}

@Override
public HttpRetryCP getRetry() {
return retry;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package com.azure.spring.cloud.autoconfigure.properties;

import com.azure.spring.cloud.autoconfigure.properties.core.authentication.TokenCredentialCP;
import com.azure.spring.cloud.autoconfigure.properties.core.client.ClientCP;
import com.azure.spring.cloud.autoconfigure.properties.core.profile.AzureProfileCP;
import com.azure.spring.cloud.autoconfigure.properties.core.proxy.ProxyCP;
import com.azure.spring.cloud.autoconfigure.properties.core.retry.RetryCP;
import com.azure.spring.core.properties.AzureProperties;
import com.azure.spring.core.properties.client.ClientProperties;
import com.azure.spring.core.properties.credential.TokenCredentialProperties;
import com.azure.spring.core.properties.profile.AzureProfile;
import com.azure.spring.core.properties.proxy.ProxyProperties;
import com.azure.spring.core.properties.retry.RetryProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

Expand All @@ -23,42 +23,42 @@ public class AzureGlobalProperties implements AzureProperties {
public static final String PREFIX = "spring.cloud.azure";

@NestedConfigurationProperty
protected final ClientProperties client = new ClientProperties();
protected final ClientCP client = new ClientCP();

@NestedConfigurationProperty
protected final ProxyProperties proxy = new ProxyProperties();
protected final ProxyCP proxy = new ProxyCP();

@NestedConfigurationProperty
protected final RetryProperties retry = new RetryProperties();
protected final RetryCP retry = new RetryCP();

@NestedConfigurationProperty
protected final TokenCredentialProperties credential = new TokenCredentialProperties();
protected final TokenCredentialCP credential = new TokenCredentialCP();

@NestedConfigurationProperty
protected final AzureProfile profile = new AzureProfile();
protected final AzureProfileCP profile = new AzureProfileCP();

@Override
public ClientProperties getClient() {
public ClientCP getClient() {
return client;
}

@Override
public ProxyProperties getProxy() {
public ProxyCP getProxy() {
return proxy;
}

@Override
public RetryProperties getRetry() {
public RetryCP getRetry() {
return retry;
}

@Override
public TokenCredentialProperties getCredential() {
public TokenCredentialCP getCredential() {
return credential;
}

@Override
public AzureProfile getProfile() {
public AzureProfileCP getProfile() {
return profile;
}
}
Loading