Announcing the stable release of Spring Cloud Azure version 4.4.0

Xiaolu Dai

We’re pleased to announce the release of Spring Cloud Azure version 4.4.0 (stable), in addition to version 4.5.0-beta.1 (beta). All Java packages are generally released in Maven. These two releases are compatible with:

  • Spring Boot versions:
    • 2.5.0 through 2.5.14
    • 2.6.0 through 2.6.11
    • 2.7.0 through 2.7.3
  • Spring Cloud versions:
    • 2020.0.3 through 2020.0.6
    • 2021.0.0 through 2021.0.3

NOTE: Spring Boot 2.5.x (x > 14), 2.6.y (y > 11), and 2.7.z (z > 3) should be supported, but they weren’t tested with this release.

Spring Cloud 2020.0.x (x > 6) and 2021.0.y (y > 3) should be supported, but they weren’t tested with this release.

The 4.4.0 release focused on improving the support of different Azure clouds, adding proxy support for Azure Active Directory (Azure AD), and improving passwordless connections to Azure Event Hubs for Kafka. For a complete list of changes, see the release notes.

The 4.5.0 Beta 1 release introduced two extra Spring Boot starters to support passwordless connections to Azure Database for MySQL and PostgreSQL. For a complete list of changes, see the release notes.

Connect to Azure AD via proxy

As of the 4.4.0 release, you can proxy the HTTP requests to Azure AD. To achieve that, provide a RestTemplateCustomizer bean. For example:

@Configuration
class DemoConfiguration {
    @Bean
    public RestTemplateCustomizer proxyRestTemplateCustomizer() {
        return (RestTemplate restTemplate) -> {
            Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXY_SERVER_HOST, PROXY_SERVER_PORT));
            SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
            requestFactory.setProxy(proxy);
            restTemplate.setRequestFactory(requestFactory);
        };
    }
}

Connect to different Azure clouds

As of the 4.4.0 release, you can configure the spring.cloud.azure.profile.cloud-type property to different Azure clouds. All service starters, such as spring-cloud-azure-starter-keyvault-secrets, will then use the specified cloud. For example:

spring:
  cloud:
    azure: 
      profile:
        cloud-type: AZURE_CHINA

If the spring.cloud.azure.profile.cloud-type property isn’t set, its default value is AZURE. The available values are AZURE, AZURE_CHINA, AZURE_GERMANY, AZURE_US_GOVERNMENT, and OTHER. If you’re using Azure Stack, set the value to OTHER and configure different endpoints via spring.cloud.azure.profile.environment.*. For a complete list of endpoint properties, see Configuration properties.

If your application connects to multiple Azure clouds, you can also set the profile.cloud-type property for each service. In the following example, the property is set for both Azure Key Vault and Azure Blob Storage:

spring:
  cloud:
    azure: 
      keyvault:
        secret:
          profile:
            cloud-type: AZURE_CHINA
      storage:
        blob:
          profile:
            cloud-type: AZURE

Connect to Azure Event Hubs for Kafka via passwordless connections

Azure Event Hubs for Kafka supports integration with Azure AD, which enables you to authenticate using Azure AD users, applications, or managed identities. Since version 4.3.0, you can achieve it by deleting the password provided via the spring.kafka.sasl.jass.config property. In version 4.4.0, we provided more flexibility by introducing a spring.cloud.azure.eventhubs.kafka.enabled property to toggle the OAuth 2.0 feature.

The only property you need when connecting to Azure Event Hubs for Kafka in a passwordless way is:

spring:
  kafka:
    bootstrap-servers: ${AZ_EVENTHUBS_NAMESPACE_NAME}.servicebus.windows.net:9093

For detailed migration instructions, see Migrate an application to use passwordless connections with Azure Event Hubs for Kafka.

Connect to Azure Database for MySQL and PostgreSQL via passwordless connections

NOTE: This feature is only available in version 4.5.0 Beta 1.

Both Azure Database for MySQL and Azure Database for PostgreSQL support integration with Azure AD. This integration allows you to authenticate using Azure AD users, applications, or managed identities.

NOTE: This feature applies to both Single Server and Flexible Server variants of Azure Database for MySQL and PostgreSQL.

To authenticate in a passwordless manner, complete the following steps:

  1. Add the dependencies:MySQL:
    <dependency>
        <groupId>com.azure.spring</groupId>
        <artifactId>spring-cloud-azure-starter-jdbc-mysql</artifactId>
        <version>4.5.0-beta.1</version>
    </dependency>

    PostgreSQL:

    <dependency>
        <groupId>com.azure.spring</groupId>
        <artifactId>spring-cloud-azure-starter-jdbc-postgresql</artifactId>
        <version>4.5.0-beta.1</version>
    </dependency>
  2. Configure the properties:
    spring:
     datasource:
       url: jdbc:mysql://${AZ_DATABASE_SERVER_NAME}.mysql.database.azure.com:3306/${AZ_DATABASE_NAME}
       username: ${AZ_AD_USERNAME}@${AZ_DATABASE_SERVER_NAME}
       azure:
         passwordless-enabled: true

    NOTE: If you’re using PostgreSQL, change the spring.datasource.url property value to something like jdbc:postgresql://${AZ_DATABASE_SERVER_NAME}.postgres.database.azure.com:5432/$AZ_DATABASE_NAME.

For more information, see Passwordless connections for Azure services.

Dependency upgrades

Here’s a list of dependency upgrades in both releases:

  • Upgrade to Azure SDK BOM 1.2.6
  • Upgrade to Azure Spring Data Cosmos DB 3.27.0
  • Upgrade to Azure Resource Manager 2.19.0

Feedback

As always, we welcome feedback and contributions. Reach out to us on StackOverflow or GitHub.

Resources

Here’s a list of links that are helpful to learn more about Spring Cloud Azure:

0 comments

Discussion is closed.

Feedback usabilla icon