共用方式為


將 Azure 負載測試資源移至另一個區域

本文說明如何將 Azure 負載測試資源移至另一個 Azure 區域。 基於幾項原因,建議您移動資源。 例如,利用新的 Azure 區域、從不同位置產生負載、符合內部原則和治理需求,或因應容量規劃需求。

Azure 負載測試資源有區域限制,無法自動跨區域移動。 當您在目標 Azure 區域中重新建立 Azure 負載測試資源時,必須在新資源中重新建立現有的負載測試。

請執行下列步驟,將資源移至另一個區域:

  1. 在 Azure Resource Manager 範本 (ARM 範本) 中匯出 Azure 負載測試資源的組態。

  2. 或者,從現有的負載測試下載任何測試成品。

  3. 使用 ARM 範本在目標區域中建立新的 Azure 負載測試資源。

  4. 在新的資源中重新建立負載測試。

  5. 選擇性地刪除上一個區域中的 Azure 負載測試資源。

必要條件

準備

若要開始使用,請匯出 Azure 負載測試資源的 ARM 範本,並下載現有負載測試的輸入成品。 稍後,您將更新 ARM 範本,以在目標 Azure 區域中部署資源。

  1. 依照這裡所述的步驟,匯出包含 Azure 負載測試資源設定和資訊的 ARM 範本。

    Screenshot that shows the ARM template to export an Azure load testing resource in the Azure portal.

  2. 下載資源中每個現有測試的輸入成品:

    1. 瀏覽至負載測試資源的 [測試] 區段。

    2. 選取測試名稱以移至測試回合清單。

    3. 針對測試回合選取省略號 ([...]),然後選取 [下載輸入檔]

      瀏覽器現在應該會開始下載壓縮資料夾,其中包含測試的所有輸入檔,例如測試組態 YAML 檔案、JMeter 指令碼,以及任何組態或資料檔案。

      Screenshot that shows how to download input files for a test.

注意

如果您使用 Azure Key Vault 來設定負載測試的祕密,可以繼續使用相同的 Key Vault。

移動

若要將資源移至目標 Azure 區域,請修改 ARM 範本、使用範本建立新的資源,然後在新的資源中重新建立負載測試。

移動資源

  1. 在 Azure 入口網站中,選取 [建立資源]

  2. 在 Marketplace 中,搜尋範本部署。 選取 [範本部署 (使用自訂範本部署)],然後選取 [建立]

    Screenshot that shows the Template deployment option in the Azure Marketplace, highlighting the Create button.

  3. 選取 [在編輯器中組建您自己的範本]

  4. 選取 [載入檔案],然後選取您先前匯出的 template.json 檔案。

  5. 更新 JSON 內容:

    1. 您可以更新 defaultValue 屬性來更新目標 Azure 負載測試資源的名稱。

      {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {
              "loadtest_name": {
                  "defaultValue": "{new-resource-name}",
                  "type": "String"
              }
          },
      
    2. 編輯位置屬性以使用目標區域。 下列範例會將目標區域設定為 eastus

      "resources": [
              {
                  "type": "Microsoft.LoadTestService/loadtests",
                  "apiVersion": "2021-12-01-preview",
                  "name": "[parameters('loadtest_name')]",
                  "location": "eastus",
      

      若要取得區域位置代碼,請參閱 Azure 位置。 區域代碼是沒有空格的區域名稱。 例如,美國東部 = eastus。

  6. 選取 [儲存]。

  7. 為目標資源輸入訂用帳戶資源群組

  8. 選取 [檢閱並建立],然後選取 [建立],以在目標 Azure 區域中建立新的 Azure 負載測試資源。

建立測試

建立 Azure 負載測試資源之後,您可以在 Azure 入口網站中重新建立負載測試

請參閱您稍早所下載 config.yaml 檔案中的測試組態,以設定負載測試設定。 上傳 Apache JMeter 指令碼和已下載輸入成品的選用組態檔。

如果您在 CI/CD 工作流程中叫用負載測試,請更新 CI/CD 管線定義中的 loadTestResource 參數,以符合新的 Azure 負載測試資源名稱。

注意

如果您已使用 Azure Key Vault 的祕密或憑證來設定任何負載測試,請務必將新資源的存取權授與 Key Vault

清除來源資源

移動完成後,請在來源區域中刪除 Azure 負載測試資源。 即使您未使用資源,仍需支付資源費用。

  1. 在 Azure 入口網站中,搜尋並選取 [Azure 負載測試]

  2. 選取您的 Azure 負載測試資源。

  3. 在資源 [概觀] 頁面上,選取 [刪除],然後確認。

警告

當您刪除 Azure 負載測試資源時,就無法再檢視相關聯的測試回合和測試結果。

下一步