Azure Spring Cloud 現已推出公開預覽版

工程 | Josh Long | 2019 年 11 月 04 日 | ...

Spring 粉絲們,大家好!今天我們很高興地宣布,由 Microsoft 和 Pivotal 共同開發的 Spring Boot 應用程式和 Spring Cloud 微服務的運行時環境 Azure Spring Cloud,現在已推出公開 Beta 版。 任何人都可以立即試用!

隨著客戶將他們的工作負載轉移到雲端,我們看到了雲原生架構,特別是微服務的使用量不斷增長。基於微服務的架構有助於提高可擴展性和速度,但實作它們可能帶來挑戰。對於許多 Java 開發人員來說,Spring Boot 和 Spring Cloud 幫助解決了這些挑戰,提供了一個穩健的平台,其中包含用於開發和運營微服務應用程式的完善模式。

問題在於,建立和維護 Spring Cloud 基礎架構(如服務註冊表、分散式追蹤和分散式配置)需要管理工作,而很少有組織準備好承擔。Spring Cloud 為您提供了機制,但如何確保安全性、擴展、負載平衡等,則取決於您。Azure Spring Cloud 是一個建構於 Microsoft Azure 之上的託管環境,具有預先配置、帶有既定做法且隨時可部署的基礎架構服務,以及基於 Spring 的應用程式的運行時環境。

以 Spring 為中心的平台

假設您有一個典型的基於 Spring Cloud 的微服務,它依賴於 Spring Cloud Config Server 中的配置,並使用 Spring Cloud Eureka DiscoveryClient 抽象實作參與服務註冊和發現。

src/main/java/demo/DemoApplication.java


package demo; 

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}
}

@RestController
class GreetingsRestController {

    private final String message;

    GreetingsRestController(@Value("${application.message}") String msg) {
        this.message = msg;
    }

    @GetMapping("/hello")
    public String hello() {
        return message;
    }
}

當然,此應用程式應附帶一個屬性文件,其中包含應用程式在服務註冊表中顯示的名稱

src/main/resources/application.properties

spring.application.name = account-service

此示範是一個簡單的應用程式。但是,要使其投入生產,您需要設定一個 Spring Cloud Config Server(包含安全性和 Git 儲存庫)、一個 Spring Cloud Eureka Server 服務註冊表(包括水平擴展),以及應用程式本身的部署。

Azure Spring Cloud 改變了一切。

投入生產... 以及更多!

要設定環境,您需要設定一個 Azure Spring Cloud 環境。

然後,您可以輕鬆地配置 Spring Cloud Config Server 及其身份驗證。

當在 Azure Spring Cloud 中將我們的服務部署到生產環境時,需要進行自動配置。使用 Maven 設定檔在您的組建中啟用它,如下所示

	<profiles>
		<profile>
			<id>cloud</id>
			<repositories>
				<repository>
					<id>nexus-snapshots</id>
					<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</repository>
			</repositories>
			<dependencies>
				<dependency>
					<groupId>com.microsoft.azure</groupId>
					<artifactId>spring-cloud-starter-azure-spring-cloud-client</artifactId>
					<version>2.1.0-SNAPSHOT</version>
				</dependency>
			</dependencies>
		</profile>
	</profiles>

使用 Maven 建置應用程式,啟動 Maven cloud 設定檔

mvn -Pcloud clean package 

您現在可以使用 Azure CLI az 部署應用程式

az spring-cloud app create -n demo-app # create the logical application 
az spring-cloud app deploy -n demo-app --jar-path target/demo-0.0.1-SNAPSHOT.jar # deploy the Boot .jar

部署應用程式後,您可以看到它可透過 Azure Spring Cloud 上託管的服務註冊表發現,例如這些處於各種狀態的應用程式

下一步是什麼

這對您意味著什麼? 恩,這僅僅是個開始! Microsoft Azure 是一個充滿活力的平台,提供有競爭力的價格、比世界上任何其他 IaaS 提供商更多的區域,以及基於 Spring 的應用程式的生產導向型環境。 我們在這篇文章中介紹了 Azure Spring Cloud 的一些功能。 但是,您仍然可以從基於 Azure Spring Cloud 的應用程式中利用更大的 Azure 平台的豐富性,並且可以利用 Spring Cloud Azure 開源專案,使繫結到 Azure 託管服務變得輕而易舉。 這些服務對我來說是最具吸引力的。 對於您的下一步,您可以探索與 Spring Security 和 Active Directory 的緊密整合,或者對 Azure CosmosDB 的反應式 Spring Data 支援,或者對 Microsoft SQL Server 的反應式 R2DBC 整合,所有這些都在 Microsoft Azure 上完全託管。

有一些很棒的資源供您追蹤。 您可以在此處完成更詳盡的培訓,並且可以在此處查看一些有關如何部署和擴展應用程式的範例

而且,當然,如果您想了解更多關於 Azure Spring Cloud 的資訊,那麼您不應該錯過 Microsoft 的 Julien Dubois 在最近的 SpringOne Platform 2019 展覽上展示的演講!

在生產環境中見!

取得 Spring 電子報

與 Spring 電子報保持聯繫

訂閱

搶先一步

VMware 提供培訓和認證,以加速您的進展。

了解更多

取得支援

Tanzu Spring 在一個簡單的訂閱中提供對 OpenJDK™、Spring 和 Apache Tomcat® 的支援和二進位檔案。

了解更多

即將舉行的活動

查看 Spring 社群中所有即將舉行的活動。

查看全部