疑難排解 Azure 流量管理員上的已降級狀態Troubleshooting degraded state on Azure Traffic Manager

本文說明如何針對顯示降級狀態的 Azure 流量管理員設定檔進行疑難排解。This article describes how to troubleshoot an Azure Traffic Manager profile that is showing a degraded status. 針對 Azure 流量管理員降級狀態進行疑難排解的第一個步驟是啟用記錄。As a first step in troubleshooting a Azure Traffic Manager degraded state is to enable logging. 如需詳細資訊,請參閱啟用資源記錄檔。Refer to Enable resource logs for more information. 在此案例中,假設您已設定流量管理員設定檔來指向您的一些 cloudapp.net 託管服務。For this scenario, consider that you have configured a Traffic Manager profile pointing to some of your cloudapp.net hosted services. 如果流量管理員的健康情況顯示 [降級]**** 狀態,則可能有一或多個端點的狀態是 [降級]****:If the health of your Traffic Manager displays a Degraded status, then the status of one or more endpoints may be Degraded:

降級端點狀態

如果流量管理員的健康情況顯示 [非使用中]**** 狀態,則可能有一或多個端點的狀態是 [非使用中]****:If the health of your Traffic Manager displays an Inactive status, then both end points may be Disabled:

非使用中流量管理員狀態

了解流量管理員探查Understanding Traffic Manager probes

  • 只有當探查收到探查路徑傳回 HTTP 200 回應時,流量管理員才會將端點視為在「線上」。Traffic Manager considers an endpoint to be ONLINE only when the probe receives an HTTP 200 response back from the probe path. 如果您的應用程式傳回任何其他 HTTP 回應碼,您應該將該回應碼新增至流量管理員設定檔的預期狀態碼範圍If you application returns any other HTTP response code you should add that response code to Expected status code ranges of your Traffic Manager profile.
  • 除非您已在流量管理員設定檔的預期狀態碼範圍中指定此回應碼,否則會將30倍重新導向回應視為失敗。A 30x redirect response is treated as failure unless you have specified this as a valid response code in Expected status code ranges of your Traffic Manager profile. 流量管理員不會探查重新導向目標。Traffic Manager does not probe the redirection target.
  • 若為 HTTP 探查,會忽略憑證錯誤。For HTTPs probes, certificate errors are ignored.
  • 只要傳回 200,探查路徑的實際內容並不重要。The actual content of the probe path doesn't matter, as long as a 200 is returned. 探查靜態內容 (例如 "/favicon.ico") 的 URL 是常用的技巧。Probing a URL to some static content like "/favicon.ico" is a common technique. 即使應用程式狀況良好,動態內容 (例如 ASP 頁面) 也不一定會傳回 200。Dynamic content, like the ASP pages, may not always return 200, even when the application is healthy.
  • 最佳做法是將探查路徑設定為具有足夠邏輯的專案,以判斷網站已啟動或關閉。A best practice is to set the probe path to something that has enough logic to determine that the site is up or down. 在上述範例中,您將路徑設為 "favicon.ico",只是測試 w3wp.exe 是否有回應。In the previous example, by setting the path to "/favicon.ico", you are only testing that w3wp.exe is responding. 此探查可能不會指出您的 Web 應用程式狀況良好。This probe may not indicate that your web application is healthy. 較好的選擇是將路徑設為 "/Probe.aspx" 之類的項目,它具有邏輯可判斷網站的健康狀態。A better option would be to set a path to a something such as "/Probe.aspx" that has logic to determine the health of the site. 例如,您可以使用效能計數器來監視 CPU 使用率,或測量失敗的要求數。For example, you could use performance counters to CPU utilization or measure the number of failed requests. 或者,您可以嘗試存取資料庫資源或工作階段狀態,以確定 Web 應用程式正在運作。Or you could attempt to access database resources or session state to make sure that the web application is working.
  • 如果設定檔中的所有端點都已降級,流量管理員會將所有端點視為狀況良好,並將流量路由傳送至所有端點。If all endpoints in a profile are degraded, then Traffic Manager treats all endpoints as healthy and routes traffic to all endpoints. 此行為可確保探查機制的問題不會造成您的服務完全中斷。This behavior ensures that problems with the probing mechanism do not result in a complete outage of your service.

疑難排解Troubleshooting

若要針對探查失敗進行疑難排解,您需要工具來顯示從探查 URL 傳回的 HTTP 狀態碼。To troubleshoot a probe failure, you need a tool that shows the HTTP status code return from the probe URL. 有許多工具可顯示原始 HTTP 回應。There are many tools available that show you the raw HTTP response.

您也可以在 Internet Explorer 中,使用 [F12 偵錯工具] 的 [網路] 索引標籤來檢視 HTTP 回應。Also, you can use the Network tab of the F12 Debugging Tools in Internet Explorer to view the HTTP responses.

在此範例中,我們想要查看來自探查 URL 的回應: HTTP/:/watestsdp2008r2.cloudapp.net:80/Probe。For this example we want to see the response from our probe URL: http://watestsdp2008r2.cloudapp.net:80/Probe. 下列 PowerShell 範例說明問題。The following PowerShell example illustrates the problem.

Invoke-WebRequest 'http://watestsdp2008r2.cloudapp.net/Probe' -MaximumRedirection 0 -ErrorAction SilentlyContinue | Select-Object StatusCode,StatusDescription

範例輸出︰Example output:

StatusCode StatusDescription
---------- -----------------
       301 Moved Permanently

請注意,我們收到重新導向回應。Notice that we received a redirect response. 如先前所述,200 以外的任何 StatusCode 都視為失敗。As stated previously, any StatusCode other than 200 is considered a failure. 流量管理員將端點狀態變更為「離線」。Traffic Manager changes the endpoint status to Offline. 若要解決此問題,請檢查網站設定,確保可以從探查路徑傳回適當的 StatusCode。To resolve the problem, check the website configuration to ensure that the proper StatusCode can be returned from the probe path. 重新設定流量管理員探查,以指向傳回 200 的路徑。Reconfigure the Traffic Manager probe to point to a path that returns a 200.

如果您的探查使用 HTTPS 通訊協定,您可能需要停用憑證檢查,以避免在測試期間發生 SSL/TLS 錯誤。If your probe is using the HTTPS protocol, you may need to disable certificate checking to avoid SSL/TLS errors during your test. 下列 PowerShell 陳述式會停用目前 PowerShell 工作階段的憑證驗證︰The following PowerShell statements disable certificate validation for the current PowerShell session:

add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
    ServicePoint srvPoint, X509Certificate certificate,
    WebRequest request, int certificateProblem) {
    return true;
    }
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

後續步驟Next Steps

關於流量管理員流量路由方法About Traffic Manager traffic routing methods

什麼是流量管理員What is Traffic Manager

雲端服務Cloud Services

Azure App ServiceAzure App Service

流量管理員的相關作業 (REST API 參考)Operations on Traffic Manager (REST API Reference)

Azure 流量管理員 CmdletAzure Traffic Manager Cmdlets