Share via


快速入門:設定適用於 Azure Spring Apps 的 Spring Cloud 設定伺服器

注意

Azure Spring Apps 是 Azure Spring Cloud 服務的新名稱。 雖然服務有新的名稱,但在我們努力更新資產,例如螢幕快照、影片和圖表時,您會在某些地方看到舊名稱一段時間。

本文適用於: ✔️基本/標準 ❌ 企業

Config Server 是分散式系統的集中式設定服務。 所使用的可插式存放庫層目前支援本機存放區、Git 和 Subversion。 在本快速入門中,您會設定組態伺服器以從 Git 存放庫取得數據。

必要條件

設定伺服器程式

執行下列命令,以專案的 Git 存放庫位置設定您的 Config Server。 將服務實例名稱>取代<為您稍早建立的服務名稱。 您在上述快速入門中設定的服務實例名稱預設值不適用於此命令。

az spring config-server git set -n <service instance name> --uri https://github.com/Azure-Samples/azure-spring-apps-samples --search-paths steeltoe-sample/config

此命令會告訴 Config Server 在範例應用程式存放庫的 steeltoe-sample/config 資料夾中尋找組態數據。 由於取得組態數據的應用程式名稱為 planet-weather-provider,因此所使用的檔案會 planet-weather-provider.yml

必要條件

  • JDK 17
  • Azure 訂用帳戶。 如果您沒有訂用帳戶,請在開始之前建立 免費帳戶
  • 或者, Azure CLI 2.45.0 版或更高版本。 使用下列命令安裝 Azure Spring Apps 擴充功能: az extension add --upgrade --name spring
  • 或者, 適用於 IntelliJ 的 Azure 工具組。

設定伺服器程式

下列程式會使用 Azure 入口網站 來設定 Config Server,以部署 PetClinic 範例

  1. 移至服務 [概觀 ] 頁面,然後選取 [設定伺服器]。

  2. 在 [預設存放庫] 區段中,將 URI 設定https://github.com/azure-samples/spring-petclinic-microservices-config

  3. 選取驗證。 驗證會檢查 Git 存放庫的架構和輔助功能,以確定其正確無誤。

    Screenshot of Azure portal showing Config Server page.

  4. 驗證完成時,請選取 [ 套用 ] 以儲存變更。

    Screenshot of Azure portal showing Config Server page with Apply button highlighted.

更新設定可能需要幾分鐘的時間。 當組態完成時,您應該會收到通知。

提示

如需使用 Config Server 私人存放庫的詳細資訊,請參閱 在 Azure Spring Apps 中設定受控 Spring Cloud Config Server。

Azure Spring Apps 組態伺服器的疑難解答

下列程式說明如何針對組態伺服器設定進行疑難解答。

  1. 在 [Azure 入口網站] 中,移至 [服務概觀] 頁面,然後選取 [記錄]。

  2. 在 [ 查詢 ] 窗格的 [顯示包含「錯誤」或「例外狀況」字詞的應用程式記錄檔中,選取 [ 執行]。

    Screenshot of Azure portal showing Azure Spring Apps query.

    記錄中的下列錯誤表示 Spring Apps 服務無法從 Config Server 找到屬性: java.lang.illegalStateException

  3. 移至服務 [概觀 ] 頁面。

  4. 選取 [診斷並解決問題]

  5. 在 [可用性和效能] 底下,選取 [疑難解答]。

    Screenshot of Azure portal showing Diagnose and solve problems page.

    Azure 入口網站 顯示[可用性與效能] 頁面,提供設定伺服器健全狀況狀態的各種資訊。

清除資源

如果您打算繼續使用後續的快速入門和教學課程,您可能會想要保留這些資源。 當您不再需要資源群組時,請刪除資源群組,以刪除資源群組中的資源。 若要刪除資源群組,請在 Azure CLI 中輸入下列命令:

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName &&
echo "Press [ENTER] to continue ..."

下一步