快速入門:使用 Azure 入口網站建立流量管理員設定檔Quickstart: Create a Traffic Manager profile using the Azure portal

本快速入門會說明如何建立流量管理員設定檔,以便為 Web 應用程式提供高可用性。This quickstart describes how to create a Traffic Manager profile that delivers high availability for your web application.

在本快速入門中,您會了解 Web 應用程式的兩個執行個體。In this quickstart, you'll read about two instances of a web application. 每個執行個體會在不同的 Azure 區域中執行。Each of them is running in a different Azure region. 您會建立以端點優先順序為基礎的流量管理員設定檔。You'll create a Traffic Manager profile based on endpoint priority. 此設定檔會將使用者流量導向執行 Web 應用程式的主要網站。The profile directs user traffic to the primary site running the web application. 流量管理員會持續監視 Web 應用程式。Traffic Manager continuously monitors the web application. 如果主要網站無法使用,它會提供自動容錯移轉至備份網站。If the primary site is unavailable, it provides automatic failover to the backup site.

如果您沒有 Azure 訂用帳戶,請立即建立免費帳戶If you don't have an Azure subscription, create a free account now.

登入 AzureSign in to Azure

登入 Azure 入口網站Sign in to the Azure portal.

PrerequisitesPrerequisites

在本快速入門中,您必須在不同的 Azure 區域 (美國東部 和西歐 ) 中部署 Web 應用程式的兩個執行個體。For this quickstart, you'll need two instances of a web application deployed in two different Azure regions (East US and West Europe). 每個執行個體都會作為流量管理員的主要和容錯移轉端點。Each will serve as primary and failover endpoints for Traffic Manager.

  1. 在畫面的左上方,選取 [建立資源] > [Web] > [Web 應用程式] 。On the upper-left side of the screen, select Create a resource > Web > Web App.

  2. 在 [建立 Web 應用程式] 中,在 [基本資訊] 索引標籤中輸入或選取下列值:In Create a Web App, type or select the following values in the Basics tab:

    • [訂用帳戶] > [資源群組] :選取 [新建] ,然後輸入 myResourceGroupTM1Subscription > Resource Group: Select Create new and then type myResourceGroupTM1.
    • [執行個體詳細資料] > [名稱] :輸入 myWebAppEastUSInstance Details > Name: Type myWebAppEastUS.
    • [執行個體詳細資料] > [發行] :選取 [程式碼] 。Instance Details > Publish: Select Code.
    • [執行個體詳細資料] > [執行階段堆疊] :選取 [ASP.NET V4.7] Instance Details > Runtime stack: Select ASP.NET V4.7
    • [執行個體詳細資料] > [作業系統] :選取 [Windows] 。Instance Details > Operating System: Select Windows.
    • 執行個體詳細資料 > 區域:選取 [美國東部] 。Instance Details > Region: Select East US.
    • [App Service 方案] > [Windows 方案 (美國東部)] :選取 [新建] ,然後輸入 myAppServicePlanEastUSApp Service Plan > Windows Plan (East US): Select Create new and then type myAppServicePlanEastUS
    • [App Service 方案] > [SKU 與大小] :選取 [標準 S1] 。App Service Plan > Sku and size: Select Standard S1.
  3. 選取 [監視] 索引標籤,或選取 [下一步: 監視] 。Select the Monitoring tab, or select Next:Monitoring. 在 [監視] 下,將 [Application Insights] > [啟用 Application Insights] 設定為 [否] 。Under Monitoring, set Application Insights > Enable Application Insights to No.

  4. 選取 [檢閱及建立] Select Review and create

  5. 檢閱設定,然後按一下 [建立] 。Review the settings, and then click Create. 成功部署 Web 應用程式時,它會建立預設網站。When the Web App successfully deploys, it creates a default web site.

  6. 依照步驟來建立名為 myWebAppWestEurope 的第二個 Web 應用程式,並將 [資源群組] 命名為 myResourceGroupTM2、將 [區域] 設定為 [西歐] 、將 [App Service 方案] 命名為 myAppServicePlanWestEurope,然後將其他設定設成跟 myWebAppEastUS 一樣。Follow the steps to create a second Web App named myWebAppWestEurope, with a Resource Group name of myResourceGroupTM2, a Region of West Europe, a App Service Plan name of myAppServicePlanWestEurope, and all the other settings the same as myWebAppEastUS.

建立流量管理員設定檔Create a Traffic Manager profile

建立可根據端點優先順序導向使用者流量的流量管理員設定檔。Create a Traffic Manager profile that directs user traffic based on endpoint priority.

  1. 在畫面的左上方,選取 [建立資源] > [網路] > [流量管理員設定檔] 。On the upper-left side of the screen, select Create a resource > Networking > Traffic Manager profile.

  2. 在 [建立流量管理員設定檔] 中,輸入或選取下列設定:In the Create Traffic Manager profile, enter, or select these settings:

    設定Setting Value
    名稱Name 為流量管理員設定檔輸入唯一的名稱。Enter a unique name for your Traffic Manager profile.
    路由方法Routing method 選取 [優先順序] 。Select Priority.
    訂用帳戶Subscription 選取您要套用流量管理員設定檔的訂用帳戶。Select the subscription you want the traffic manager profile applied to.
    資源群組Resource group 選取 [myResourceGroupTM1] 。Select myResourceGroupTM1.
    LocationLocation 此設定會參考資源群組的位置。This setting refers to the location of the resource group. 其不會影響將全球部署的流量管理員設定檔。It has no effect on the Traffic Manager profile that will be deployed globally.
  3. 選取 [建立] 。Select Create.

新增流量管理員端點Add Traffic Manager endpoints

將「美國東部」 中的網站新增為所有使用者流量的主要路由目標端點。Add the website in the East US as primary endpoint to route all the user traffic. 將「西歐」 中的網站新增為容錯移轉端點。Add the website in West Europe as a failover endpoint. 當主要端點無法使用時,流量就會自動路由傳送到容錯移轉端點。When the primary endpoint is unavailable, traffic automatically routes to the failover endpoint.

  1. 在入口網站的搜尋列中,輸入您在上一節建立的流量管理員設定檔名稱。In the portal's search bar, enter the Traffic Manager profile name that you created in the preceding section.

  2. 從搜尋結果中選取設定檔。Select the profile from the search results.

  3. 在 [流量管理員設定檔] 的 [設定] 區段中,選取 [端點] ,然後選取 [新增] 。In Traffic Manager profile, in the Settings section, select Endpoints, and then select Add.

  4. 輸入或選取下列設定:Enter, or select, these settings:

    設定Setting Value
    類型Type 選取 [Azure 端點] 。Select Azure endpoint.
    名稱Name 輸入 myPrimaryEndpoint 。Enter myPrimaryEndpoint.
    目標資源類型Target resource type 選取 [App Service] 。Select App Service.
    目標資源Target resource 選取 [選擇 App Service] > [美國東部] 。Select Choose an app service > East US.
    優先順序Priority 選取 [1] 。Select 1. 狀況良好時,所有流量都會送至這個端點。All traffic goes to this endpoint when it's healthy.

    您將端點新增至流量管理員設定檔的螢幕擷取畫面。

  5. 選取 [確定] 。Select OK.

  6. 若要為第二個 Azure 區域建立容錯移轉端點,請使用下列設定重複步驟 3 和 4:To create a failover endpoint for your second Azure region, repeat steps 3 and 4 with these settings:

    設定Setting Value
    類型Type 選取 [Azure 端點] 。Select Azure endpoint.
    名稱Name 輸入 myFailoverEndpoint 。Enter myFailoverEndpoint.
    目標資源類型Target resource type 選取 [App Service] 。Select App Service.
    目標資源Target resource 選取 [選擇 App Service] > [西歐] 。Select Choose an app service > West Europe.
    優先順序Priority 選取 2Select 2. 如果主要端點狀況不良,則所有流量都會送到此容錯移轉端點。All traffic goes to this failover endpoint if the primary endpoint is unhealthy.
  7. 選取 [確定] 。Select OK.

新增好兩個端點之後,它們會顯示在 [流量管理員設定檔] 中。When you're done adding the two endpoints, they're displayed in Traffic Manager profile. 請注意,其監視狀態目前為 [線上] 。Notice that their monitoring status is Online now.

測試流量管理員設定檔Test Traffic Manager profile

在本節中,您會檢查流量管理員設定檔的網域名稱。In this section, you'll check the domain name of your Traffic Manager profile. 您也會將主要端點設定為無法使用。You'll also configure the primary endpoint to be unavailable. 最後,您可以看到 Web 應用程式仍可使用。Finally, you get to see that the web app is still available. 這是因為流量管理員將流量傳送至容錯移轉端點。It's because Traffic Manager sends the traffic to the failover endpoint.

檢查 DNS 名稱Check the DNS name

  1. 在入口網站的搜尋列中,搜尋您在上一節建立的流量管理員設定檔名稱。In the portal’s search bar, search for the Traffic Manager profile name that you created in the preceding section.

  2. 選取流量管理員設定檔。Select the traffic manager profile. [概觀] 頁面隨即出現。The Overview appears.

  3. [流量管理員設定檔] 會顯示新建立之流量管理員設定檔的 DNS 名稱。The Traffic Manager profile displays the DNS name of your newly created Traffic Manager profile.

    流量管理員 DNS 名稱的位置螢幕擷取畫面

檢視流量管理員的運作View Traffic Manager in action

  1. 在網頁瀏覽器中,輸入流量管理員設定檔的 DNS 名稱,以檢視 Web 應用程式的預設網站。In a web browser, enter the DNS name of your Traffic Manager profile to view your Web App's default website.

    注意

    在此快速入門案例中,所有要求都會路由傳送至主要端點。In this quickstart scenario, all requests route to the primary endpoint. 它會設定為 [優先順序 1] 。It is set to Priority 1.

    確認流量管理員設定檔可用性的網頁螢幕擷取畫面

  2. 若要檢視流量管理員容錯移轉的運作,請停用主要網站:To view Traffic Manager failover in action, disable your primary site:

    1. 在 [流量管理員設定檔] 頁面中,從 [概觀] 區段選取 [myPrimaryEndpoint] 。In the Traffic Manager Profile page, from the Overview section, select myPrimaryEndpoint.
    2. 在 [myPrimaryEndpoint] 中,選取 [已停用] > [儲存] 。In myPrimaryEndpoint, select Disabled > Save.
    3. 關閉 myPrimaryEndpoint 。Close myPrimaryEndpoint. 請注意,狀態目前為 [已停用] 。Notice that the status is Disabled now.
  3. 複製上一個步驟中的流量管理員設定檔 DNS 名稱,以在新的網頁瀏覽器工作階段中檢視網站。Copy the DNS name of your Traffic Manager Profile from the preceding step to view the website in a new web browser session.

  4. 確認 Web 應用程式仍可使用。Verify that the web app is still available.

主要端點無法使用,因此您會路由傳送至容錯移轉端點。The primary endpoint isn't available, so you were routed to the failover endpoint.

清除資源Clean up resources

完成時,請刪除資源群組、Web 應用程式和所有相關資源。When you're done, delete the resource groups, web applications, and all related resources. 若要這麼做,從儀表板中選取每個個別項目,然後選取每個頁面頂端的 [刪除] 。To do so, select each individual item from your dashboard and select Delete at the top of each page.

後續步驟Next steps

在本快速入門中,您建立了流量管理員設定檔。In this quickstart, you created a Traffic Manager profile. 它可讓您引導高可用性 Web 應用程式的使用者流量。It allows you to direct user traffic for high-availability web applications. 若要深入了解如何路由傳送流量,請繼續進行流量管理員的教學課程。To learn more about routing traffic, continue to the Traffic Manager tutorials.