{"id":2775,"date":"2023-08-08T15:43:39","date_gmt":"2023-08-08T22:43:39","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sdk\/?p=2775"},"modified":"2023-08-09T11:27:50","modified_gmt":"2023-08-09T18:27:50","slug":"announcing-spring-cloud-azure-4-9-0-and-5-3-0-now-generally-available","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sdk\/announcing-spring-cloud-azure-4-9-0-and-5-3-0-now-generally-available\/","title":{"rendered":"Announcing Spring Cloud Azure 4.9.0 and 5.3.0: Now Generally Available"},"content":{"rendered":"<p>We&#8217;re thrilled to announce the general availability of Spring Cloud Azure 4.9.0 and 5.3.0. These major releases bring increased compatibility with Spring Boot 2 for 4.9.0 and Spring Boot 3 for 5.3.0.<\/p>\n<h2>Highlighted features and improvements<\/h2>\n<h3>Spring Cloud Azure 5.3.0<\/h3>\n<p>This release includes noteworthy features and enhancements such as:<\/p>\n<ul>\n<li>Spring Data Cosmos and Spring Data Cosmos Starter, now compatible with Spring Boot 3.<\/li>\n<li>Compatibility with Spring Boot 3.1.<\/li>\n<li>Introduction of a new Spring Boot starter for Azure Event Grid.<\/li>\n<li>Passwordless connection support for Azure Service Bus JMS.<\/li>\n<li>Upgrades to <code>azure-sdk-bom<\/code> (version 1.2.14) and <code>azure-resourcemanager<\/code> (version 2.28.0).<\/li>\n<\/ul>\n<h3>Spring Cloud Azure 4.9.0<\/h3>\n<p>This version comes with the following additions:<\/p>\n<ul>\n<li>A new Spring Boot starter for Azure Event Grid.<\/li>\n<li>Upgrades to <code>azure-sdk-bom<\/code> (version 1.2.14) and <code>azure-resourcemanager<\/code> (version 2.28.0).<\/li>\n<\/ul>\n<p>Moreover, we&#8217;ve launched the <code>4.9.0-beta.1<\/code> version of <code>spring-cloud-azure-starter-openai<\/code>, extending support to the Azure OpenAI service.<\/p>\n<p>Let&#8217;s delve deeper into the new offerings!<\/p>\n<h2>What&#8217;s new?<\/h2>\n<h3>Spring Data Cosmos<\/h3>\n<p>Spring Data Cosmos 5.3.0 is the first GA version compatible with Spring Boot 3. For more information, see the Spring Data Cosmos <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-java\/blob\/main\/sdk\/spring\/azure-spring-data-cosmos\/CHANGELOG.md\">changelog<\/a>.<\/p>\n<p>There&#8217;s no change in how you use Spring Data Cosmos. Just add the starter to your project:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;com.azure.spring&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-cloud-azure-starter-cosmos&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<p>Next, configure the Cosmos properties in your <code>application.properties<\/code> file:<\/p>\n<pre><code class=\"language-properties\">spring.cloud.azure.cosmos.endpoint=&lt;your-azure-cosmos-endpoint&gt;\r\nspring.cloud.azure.cosmos.database=&lt;your-azure-cosmos-database&gt;<\/code><\/pre>\n<p>This configuration uses the available credential on your local environment, such as Azure CLI, to connect to the Azure Cosmos DB database. To configure other types of authentication principals, see <a href=\"https:\/\/learn.microsoft.com\/azure\/developer\/java\/spring-framework\/authentication#authenticate-with-azure-active-directory\">Authenticate with Entra ID<\/a>.<\/p>\n<p>You can define a repository in your project to save and query data as follows:<\/p>\n<pre><code class=\"language-java\">@Repository\r\npublic interface UserRepository extends CosmosRepository&lt;User, String&gt; {}\r\n\r\n@Service\r\npublic class CosmosService {\r\n\r\n    @Autowired\r\n    private UserRepository userRepository;\r\n\r\n    public void someMethod() {\r\n        User testUser = new User(USER_ID, \"testFirstName\", \"testLastName\", \"test address line one\");\r\n        userRepository.save(testUser);\r\n        Optional&lt;User&gt; user = userRepository.findById(USER_ID);\r\n        userRepository.delete(testUser);\r\n    }\r\n}<\/code><\/pre>\n<h3>Autoconfiguration of Azure Event Grid<\/h3>\n<p>Azure Event Grid enables easy construction of event-based architecture applications. With the new Spring Cloud Azure starter for Event Grid, Event Grid client autoconfiguration is a breeze. For more information about Azure Event Grid, see <a href=\"https:\/\/learn.microsoft.com\/azure\/event-grid\/overview\">What is Event Grid?<\/a>.<\/p>\n<p>To utilize this feature, add the starter to your project:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;com.azure.spring&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-cloud-azure-starter-eventgrid&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<p>Then, configure the Event Grid properties in your <code>application.properties<\/code> file:<\/p>\n<pre><code class=\"language-properties\">spring.cloud.azure.eventgrid.endpoint=https:\/\/xxx.eventgrid.azure.net\/api\/events\r\nspring.cloud.azure.eventgrid.key=&lt;your-event-grid-key&gt;<\/code><\/pre>\n<p>You can also use Entra ID principals to connect to the Event Grid service. <a href=\"https:\/\/learn.microsoft.com\/azure\/developer\/java\/spring-framework\/authentication#authenticate-with-azure-active-directory\">Authenticate with Entra ID<\/a> offers guidance on configuring other types of authentication principals.<\/p>\n<p>Here&#8217;s how you can autowire the Event Grid client:<\/p>\n<pre><code class=\"language-java\">@Autowired\r\nEventGridPublisherClient&lt;EventGridEvent&gt; client;\r\n\r\npublic void someMethod(String user) {\r\n    \/\/ ...\r\n    \/\/ topic must be set when sending to an Event Grid Domain.\r\n    EventGridEvent event = new EventGridEvent(\"A user is created\",\r\n                                              \"User.Created.Object\",\r\n                                              BinaryData.fromObject(user),\r\n                                              \"0.1\");\r\n    client.sendEvent(event);\r\n    \/\/ ...\r\n}<\/code><\/pre>\n<h3>Passwordless connection to Azure Service Bus JMS<\/h3>\n<p>Prior to the support of passwordless connections, a connection to Azure Service Bus required a connection string. However, with the new feature, you can connect to Azure Service Bus JMS using Managed Identity or any Entra ID principal. To learn more about passwordless connections, see <a href=\"https:\/\/aka.ms\/passwordless-connections\">aka.ms\/passwordless-connections<\/a>.<\/p>\n<p>To connect to Azure Service Bus JMS with a passwordless connection, add the starter to your project:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;com.azure.spring&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-cloud-azure-starter-servicebus-jms&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<p>Then, configure the necessary properties in <code>application.properties<\/code>:<\/p>\n<pre><code class=\"language-properties\">spring.jms.servicebus.passwordless-enabled=true\r\nspring.jms.servicebus.namespace=&lt;your-servicebus-namespace&gt;\r\nspring.jms.servicebus.pricing-tier=&lt;your-servicebus-pricing-tier&gt; # e.g. standard\r\nspring.cloud.azure.credential.managed-identity-enabled=true\r\nspring.cloud.azure.credential.client-id=&lt;your-user-assigned-managed-identity-id&gt;<\/code><\/pre>\n<p>This configuration uses the user-assigned managed identity to connect to the Service Bus. To configure other types of authentication principals, see <a href=\"https:\/\/learn.microsoft.com\/azure\/developer\/java\/spring-framework\/authentication#authenticate-with-azure-active-directory\">Authenticate with Entra ID<\/a>.<\/p>\n<p>Afterward, you can use the Spring <code>JmsTemplate<\/code> or <code>@JmsListener<\/code> in your application:<\/p>\n<pre><code class=\"language-java\">@SpringBootApplication\r\n@EnableJms\r\npublic class ServiceBusJMSApplication implements CommandLineRunner {\r\n\r\n    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceBusJMSApplication.class);\r\n    private static final String QUEUE_NAME = \"&lt;QueueName&gt;\";\r\n\r\n    @Autowired\r\n    private JmsTemplate jmsTemplate;\r\n\r\n    public static void main(String[] args) {\r\n        SpringApplication.run(ServiceBusJMSApplication.class, args);\r\n    }\r\n\r\n    @Override\r\n    public void run(String... args) {\r\n        LOGGER.info(\"Sending message\");\r\n        jmsTemplate.convertAndSend(QUEUE_NAME, \"Hello Word\");\r\n    }\r\n\r\n    @JmsListener(destination = QUEUE_NAME, containerFactory = \"jmsListenerContainerFactory\")\r\n    public void receiveMessage(String message) {\r\n        LOGGER.info(\"Message received: {}\", message);\r\n    }\r\n\r\n}<\/code><\/pre>\n<h3>Azure OpenAI support<\/h3>\n<p><a href=\"https:\/\/learn.microsoft.com\/azure\/cognitive-services\/openai\/overview\">Azure OpenAI<\/a> is a managed service enabling developers to deploy, tune, and generate content from OpenAI models on Azure resources.<\/p>\n<p>The Spring Cloud Azure starter for Azure OpenAI allows autoconfiguration of the <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-java\/blob\/main\/sdk\/openai\/azure-ai-openai\/README.md\">OpenAI client<\/a> provided by the Azure SDK for Java. To use this feature, add the starter to your project:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;com.azure.spring&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-cloud-azure-starter-openai&lt;\/artifactId&gt;\r\n  &lt;version&gt;4.9.0-beta.1&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<p>Next, configure the OpenAI properties in your <code>application.properties<\/code> file:<\/p>\n<pre><code class=\"language-properties\">spring.cloud.azure.openai.endpoint=https:\/\/xxx.openai.azure.com\/\r\nspring.cloud.azure.openai.key=&lt;your-azure-openai-key&gt;\r\n# or you can use the key of the public non-Azure OpenAI\r\n# spring.cloud.azure.openai.non-azure-openai-key=&lt;your-public-openai-key&gt;<\/code><\/pre>\n<p>Then, you&#8217;re ready to autowire the OpenAI client:<\/p>\n<pre><code class=\"language-java\">@Autowired\r\nprivate OpenAIClient client;\r\n\r\npublic void someMethod() {\r\n    List&lt;String&gt; prompt = List.of(\"How many breeds of dogs are there in the world?\");\r\n\r\n    Completions completions = client.getCompletions(\"gpt-35-turbo\", new CompletionsOptions(prompt));\r\n\r\n    for (Choice choice : completions.getChoices()) {\r\n        System.out.printf(\"Index: %d, Text: %s.%n\", choice.getIndex(), choice.getText());\r\n    }\r\n}<\/code><\/pre>\n<h3>One dependency BOM for all Spring Cloud Azure components<\/h3>\n<p>The <code>spring-cloud-azure-dependencies<\/code> BOM manages all Spring Cloud Azure components, including Cosmos and App Configuration. You can add the BOM to your project as follows:<\/p>\n<pre><code class=\"language-xml\">&lt;dependencyManagement&gt; \r\n  &lt;dependencies&gt; \r\n    &lt;dependency&gt; \r\n      &lt;groupId&gt;com.azure.spring&lt;\/groupId&gt; \r\n      &lt;artifactId&gt;spring-cloud-azure-dependencies&lt;\/artifactId&gt; \r\n      &lt;version&gt;5.3.0&lt;\/version&gt; &lt;!-- 4.9.0 or 4.9.0-beta.1 --&gt;\r\n      &lt;type&gt;pom&lt;\/type&gt; \r\n      &lt;scope&gt;import&lt;\/scope&gt; \r\n    &lt;\/dependency&gt; \r\n  &lt;\/dependencies&gt; \r\n&lt;\/dependencyManagement&gt; <\/code><\/pre>\n<p>This configuration allows all Spring Cloud Azure component versions to be managed. For example:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;com.azure.spring&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-cloud-azure-starter-servicebus-jms&lt;\/artifactId&gt;\r\n  &lt;!-- The version can be omitted --&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<h3>Compatibility with Spring Boot 3.1<\/h3>\n<p>Spring Cloud Azure 5.3.0 is now compatible with <a href=\"https:\/\/spring.io\/blog\/2023\/05\/18\/spring-boot-3-1-0-available-now\">Spring Boot 3.1<\/a>. This version is compatible with both Spring Boot 3.0.x and 3.1.x. Check https:\/\/aka.ms\/spring\/versions for more information on versioning details.<\/p>\n<h2>Feedback<\/h2>\n<p>Your feedback and contributions are always welcome on <a href=\"https:\/\/stackoverflow.com\/questions\/tagged\/spring-cloud-azure\">StackOverflow<\/a>\u202for\u202f<a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-java\/issues?q=is%3Aissue+is%3Aopen+label%3Aazure-spring\">GitHub<\/a>.<\/p>\n<h2>Resources<\/h2>\n<p>To learn more about Spring Cloud Azure, we invite you to visit the following links:<\/p>\n<ul>\n<li><a href=\"https:\/\/aka.ms\/spring\/docs\">Reference Documentation<\/a><\/li>\n<li><a href=\"https:\/\/aka.ms\/spring\/msdocs\">Conceptual Documentation<\/a><\/li>\n<li><a href=\"https:\/\/aka.ms\/spring\/samples\">Code Samples<\/a><\/li>\n<li><a href=\"https:\/\/aka.ms\/spring\/versions\">Spring Version Mapping<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This post announces the release of Spring Cloud Azure 4.9.0 and 5.3.0.<\/p>\n","protected":false},"author":103258,"featured_media":2783,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[160,871,872,854],"class_list":["post-2775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sdk","tag-java","tag-spring","tag-spring-cloud-azure","tag-stable-releases"],"acf":[],"blog_post_summary":"<p>This post announces the release of Spring Cloud Azure 4.9.0 and 5.3.0.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/2775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/users\/103258"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/comments?post=2775"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/2775\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media\/2783"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media?parent=2775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/categories?post=2775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/tags?post=2775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}