共用方式為


教學課程:使用 Azure Chaos Studio 排程週期性實驗

Azure Chaos Studio 可讓您執行混沌實驗,刻意讓應用程式或服務的一部分失敗,以確認其能夠針對這些失敗進行復原。 定期執行這些混沌實驗會很有用,可確保應用程式的復原能力未迴歸,或可符合合規性需求。 在本教學課程中,您會使用邏輯應用程式來觸發實驗每天執行一次。

在本教學課程中,您會了解如何:

  • 建立邏輯應用程式。
  • 設定邏輯應用程式以觸發混沌實驗每天啟動一次。
  • 測試邏輯應用程式是否已正確設定。

必要條件

建立邏輯應用程式

邏輯應用程式是可根據排程執行的自動化工作流程。 本教學課程中使用的邏輯應用程式會使用週期排程來啟動混沌實驗。

  1. 使用您的 Azure 帳戶認證,登入 Azure 入口網站。 在 Azure 首頁上,選取 [建立資源]

  2. 在 Azure Marketplace 功能表上,選取 [整合]>[邏輯應用程式]

    Screenshot that shows the Azure Marketplace menu with Integration and Logic App selected.

  3. 在 [建立邏輯應用程式] 窗格上,提供這裡所述的資訊,其描述您想要建立的邏輯應用程式。

    Screenshot that shows the Logic App creation pane and the information to provide for the new logic app.

    屬性 數值 Description
    訂用帳戶 <Azure-訂閱-名稱> 您的 Azure 訂用帳戶名稱。 此範例使用 Azure Chaos Studio 示範
    資源群組 chaosstudiodemo Azure 資源群組的名稱,其用來組織相關資源。 此範例會建立新的資源群組,名為 chaosstudiodemo
    類型 耗用 邏輯應用程式資源類型。 設定為 [取用]
    名稱 scheduleExperiment 您的邏輯應用程式名稱,其中只能包含字母、數字、連字號、底線、括弧和句點。 此範例使用 scheduleExperiment
    地點 美國東部 用來存放邏輯應用程式資訊的區域。 此範例使用美國東部
    啟用記錄分析 No 設定邏輯應用程式的診斷記錄。 設定為 [否]
  4. 當您完成時,選取 [檢閱 + 建立]。 在 Azure 驗證邏輯應用程式的相關資訊之後,請選取 [建立]

  5. 在 Azure 部署您的應用程式之後,請選取 [移至資源]

    Azure 會開啟 Logic Apps 範本選取窗格,其中顯示簡介影片、常用的觸發程序,以及邏輯應用程式範本模式。

新增週期觸發程序

接下來,新增週期觸發程序,此觸發程序會根據指定的排程執行。 每個邏輯應用程式都必須使用觸發程序啟動,而該觸發程序會在特定事件發生或新資料符合特定條件時引發。

  1. 向下捲動影片和觸發程序直到 [範本]區段,然後選取 [空白邏輯應用程式]

    Screenshot that shows the Logic Apps template selection pane with Blank Logic App selected.

  2. 在 [Logic Apps 設計工具] 搜尋方塊中,輸入 recurrence,然後選取名為 Recurrence 的觸發程序。

    Screenshot that shows the Logic Apps Designer search box that contains the recurrence search term and in the Triggers list, the Recurrence trigger appears selected.

  3. 在 [週期] 圖形中,選取省略符號 (...) 按鈕,然後選取 [重新命名]。 使用「每天早上開始混沌實驗」的描述,將觸發程序重新命名。

    Screenshot that shows the ellipses button selected, the Settings list open, and the Rename command selected.

  4. 在觸發程序內,變更這些屬性,如下所述和所示。

    Screenshot that shows the changes to the trigger's interval and frequency.

    屬性 必填 Description
    間隔 Yes 1 在檢查之間所要等待的間隔數目
    頻率 Yes Day 要用於週期的時間單位
  5. 在 [間隔] 和 [頻率] 底下,開啟 [新增參數] 清單。 選取這些屬性以新增至觸發程序:

    • 在這幾小時內
    • 在這幾分鐘內

    Screenshot that shows the opened Add new parameter list and these selected properties: On these days, At these hours, and At these minutes.

  6. 現在設定屬性的值,如下所示及說明。

    Screenshot that shows the action properties set to the values as described in the following table.

    屬性 數值 Description
    在這幾小時內 8 只在您將 [頻率] 設定為 [周] 或 [日] 時,才可以使用此設定。 對於此週期,選取幾小時。 這個範例會在 8 點整點執行。
    在這幾分鐘內 00 只在您將 [頻率] 設定為 [周] 或 [日] 時,才可以使用此設定。 對於此週期,選取幾分鐘。 這個範例會在零點整點執行。

    這個觸發程序會在每個工作日上午 8:00 引發。 [預覽] 方塊會顯示週期排程。 如需詳細資訊,請參閱排程工作和工作流程工作流程動作和觸發程序

  7. 儲存邏輯應用程式。 在設計師工具列上選取儲存

新增執行混沌實驗動作

現在您已擁有觸發程序,請新增啟動實驗的動作。 本教學課程使用 [叫用資源作業] 動作來啟動實驗。

  1. 在 Logic Apps 設計工具中,於週期觸發程序之下,選取 [新增步驟]

  2. 在 [選擇作業] 下,輸入 [叫用資源作業]。 選取 [動作] 下名為 [叫用資源作業] 的選項。

    Screenshot that shows the search bar filled in with Invoke resource operation.

  3. 設定儲存實驗的正確 [租用戶],然後選取 [登入]

  4. 登入該租用戶的 Azure 帳戶。

  5. 現在設定動作屬性的值,如下所示及說明。

    Screenshot that shows the properties set to the values as described in the following table.

    屬性 數值 Description
    訂用帳戶 <Azure-訂閱-名稱> 部署混沌實驗的 Azure 訂用帳戶名稱。 此範例使用 Azure Chaos Studio 示範
    資源群組 <Resource-group-name> 部署混沌實驗的資源群組名稱。 此範例使用 chaosstudiodemo
    資源提供者 Microsoft.Chaos Chaos Studio 資源提供者。
    短資源識別碼 experiments/<Resource-group-name> 混沌實驗的名稱前面加上 experiments/
    用戶端 API 版本 2023-11-01 Chaos Studio REST API 版本。
    動作名稱 start Chaos Studio 實驗動作的名稱。 一律啟動
  6. 儲存邏輯應用程式。 在設計師工具列上選取儲存

測試邏輯應用程式

現在,測試邏輯應用程式,以確定其已成功啟動您的實驗。

  1. 關閉邏輯應用程式設計工具。

  2. 在邏輯應用程式概觀上,選取 [執行觸發程序]>[執行]

    Screenshot that shows the Run Trigger option.

  3. 移至 Azure 入口網站中的混沌實驗,並確認 [狀態] 已設定為 [執行中]

    Screenshot that shows the experiment status.

清除資源

如果您不打算繼續使用此應用程式,請使用下列步驟刪除邏輯應用程式:

  1. 在邏輯應用程式概觀上,選取 [刪除]
  2. 輸入邏輯應用程式名稱,然後選取 [刪除]

下一步

現在您已設定實驗的排程,您可以: