您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

监视任意网站的可用性Monitor the availability of any website

部署 Web 应用/网站后,可以设置重复执行的测试来监视可用性和响应能力。After you've deployed your web app/website, you can set up recurring tests to monitor availability and responsiveness. Azure Application Insights 将来自全球各地的 Web 请求定期发送到应用程序。Azure Application Insights sends web requests to your application at regular intervals from points around the world. 如果应用程序无响应或响应太慢,它可以提醒你。It can alert you if your application isn't responding, or if it responds too slowly.

对于可以从公共 Internet 访问的任何 HTTP 或 HTTPS 终结点,均可设置可用性测试。You can set up availability tests for any HTTP or HTTPS endpoint that is accessible from the public internet. 无需更改要测试的网站。You don't have to make any changes to the website you're testing. 事实上,该网站甚至不需要是你拥有的网站。In fact, it doesn't even have to be a site you own. 可以测试服务所依赖的 REST API 的可用性。You can test the availability of a REST API that your service depends on.

可用性测试类型:Types of availability tests:

有三种类型的可用性测试:There are three types of availability tests:

  • URL ping 测试:可以在 Azure 门户中创建的简单测试。URL ping test: a simple test that you can create in the Azure portal.
  • 多步骤 Web 测试:记录一系列 Web 请求,这些请求可以通过再现来测试更复杂的场景。Multi-step web test: A recording of a sequence of web requests, which can be played back to test more complex scenarios. 多步骤 Web 测试在 Visual Studio Enterprise 中创建并上传到门户执行。Multi-step web tests are created in Visual Studio Enterprise and uploaded to the portal for execution.
  • 自定义跟踪可用性测试:如果决定创建自定义应用程序以运行可用性测试,则可以使用 TrackAvailability() 方法将结果发送到 Application Insights。Custom Track Availability Tests: If you decide to create a custom application to run availability tests, the TrackAvailability() method can be used to send the results to Application Insights.

对于每个 Application Insights 资源,最多可以创建 100 个可用性测试。You can create up to 100 availability tests per Application Insights resource.

创建 Application Insights 资源Create an Application Insights resource

若要创建可用性测试,首先需创建 Application Insights 资源。In order to create an availability test, you first need to create an Application Insights resource. 如果已创建资源,请转到下一部分,创建 URL Ping 测试If you have already created a resource, proceed to the next section to create a URL Ping test.

在 Azure 门户中选择“创建资源” > “开发人员工具” > “Application Insights” ,创建 Application Insights 资源From the Azure portal, select Create a resource > Developer Tools > Application Insights and create an Application Insights resource.

创建 URL ping 测试Create a URL ping test

“URL ping 测试”这个名称有点用词不当。The name "URL ping test" is a bit of a misnomer. 澄清一下,此测试不使用 ICMP(Internet 控制消息协议)来检查站点的可用性,To be clear, this test is not making any use of ICMP (Internet Control Message Protocol) to check your site's availability. 而是使用更高级的 HTTP 请求功能来验证终结点是否响应。Instead it uses more advanced HTTP request functionality to validate whether an endpoint is responding. 它还度量与该响应相关联的性能,并添加设置自定义成功标准的功能,该标准与更高级的功能(例如分析从属请求、允许重试)耦联。It also measures the performance associated with that response, and adds the ability to set custom success criteria coupled with more advanced features like parsing dependent requests, and allowing for retries.

若要创建第一个可用性请求,请打开“可用性”窗格并选择“创建测试”。 To create your first availability request, open the Availability pane and select Create Test.

至少填写网站的 URL

创建测试Create a test

设置Setting 说明Explanation
URLURL URL 可以是要测试的任何网页,但必须在公共 Internet 中可见。The URL can be any web page you want to test, but it must be visible from the public internet. 该 URL 可以包括查询字符串。The URL can include a query string. 因此,例如,可以稍微训练一下数据库。So, for example, you can exercise your database a little. 如果 URL 解析为重定向,最多可以跟踪 10 个重定向。If the URL resolves to a redirect, we follow it up to 10 redirects.
分析从属请求Parse dependent requests 测试会请求图像、脚本、样式文件以及其他属于受测网页的文件。Test requests images, scripts, style files, and other files that are part of the web page under test. 记录的响应时间包括获取这些文件所耗费的时间。The recorded response time includes the time taken to get these files. 如果无法在超时期限内为整个测试成功下载这些资源中的任一个,则表明测试失败。The test fails if any of these resources cannot be successfully downloaded within the timeout for the whole test. 如果不选中此选项,则测试只请求指定 URL 的文件。If the option is not checked, the test only requests the file at the URL you specified. 启用此选项会导致更严格的检查。Enabling this option results in a stricter check. 测试有时候可能会失败,在手动浏览站点时,可能注意不到这一点。The test could fail for cases, which may not be noticeable when manually browsing the site.
启用重试Enable retries 测试失败时,会在短时间后重试。when the test fails, it is retried after a short interval. 仅当连续三次尝试失败时,才报告失败。A failure is reported only if three successive attempts fail. 然后,将按照一般的测试频率执行后续测试。Subsequent tests are then performed at the usual test frequency. 重试会暂停,直到下次成功为止。Retry is temporarily suspended until the next success. 可在每个测试位置单独应用此规则。This rule is applied independently at each test location. 建议使用此选项We recommend this option. 平均大约有 80% 的失败可在重试后消除。On average, about 80% of failures disappear on retry.
测试频率Test frequency 设置从每个测试位置运行测试的频率。Sets how often the test is run from each test location. 如果有五个测试位置,且默认频率为五分钟,则平均每隔一分钟测试站点一次。With a default frequency of five minutes and five test locations, your site is tested on average every minute.
测试位置Test locations 是服务器从其将 Web 请求发送到 URL 的位置。Are the places from where our servers send web requests to your URL. 建议最低测试位置数目为 5,以确保可以将网站中的问题与网络问题区分开来。Our minimum number of recommended test locations is five in order to insure that you can distinguish problems in your website from network issues. 最多可以选择 16 个位置。You can select up to 16 locations.

如果 URL 在公共 Internet 中不可见,可以选择性地打开防火墙,只允许测试事务通过If your URL is not visible from the public internet, you can choose to selectively open up your firewall to allow only the test transactions through. 若要详细了解可用性测试代理的防火墙例外,请参阅 IP 地址指南To learn more about the firewall exceptions for our availability test agents, consult the IP address guide.


强烈建议从多个位置进行测试,至少为 5 个位置We strongly recommend testing from multiple locations with a minimum of five locations. 这是为了防止可能由特定位置的暂时性问题导致的虚假警报。This is to prevent false alarms that may result from transient issues with a specific location. 此外,我们发现最佳配置是使测试位置的数目等于警报位置阈值 + 2In addition we have found that the optimal configuration is to have the number of test locations be equal to the alert location threshold + 2.

成功标准Success criteria

设置Setting 说明Explanation
测试超时Test timeout 减少此值可以接收有关响应变慢的警报。Decrease this value to be alerted about slow responses. 如果未在这段时间内收到站点的响应,则将测试视为失败。The test is counted as a failure if the responses from your site have not been received within this period. 如果选择了“分析依赖请求”,则必须在这段时间内收到所有图像、样式文件、脚本和其他依赖资源 。If you selected Parse dependent requests, then all the images, style files, scripts, and other dependent resources must have been received within this period.
HTTP 响应HTTP response 视为成功的返回状态代码。The returned status code that is counted as a success. 代码 200 指示返回了正常网页。200 is the code that indicates that a normal web page has been returned.
内容匹配Content match 类似于“欢迎!”的字符串。A string, like "Welcome!" 我们测试区分大小写的匹配项是否出现在每个响应中。We test that an exact case-sensitive match occurs in every response. 它必须是不带通配符的纯字符串。It must be a plain string, without wildcards. 别忘了,如果页面内容更改,可能需要更新。Don't forget that if your page content changes you might have to update it. 内容匹配仅支持英文字符Only English characters are supported with content match


设置Setting 说明Explanation
近实时(预览)Near-realtime (Preview) 我们建议使用近实时警报。We recommend using Near-realtime alerts. 在创建可用性测试后会配置此类警报。Configuring this type of alert is done after your availability test is created.
经典Classic 我们不再建议对新的可用性测试使用经典警报。We no longer recommended using classic alerts for new availability tests.
警报位置阈值Alert location threshold 建议最少 3/5 个位置。We recommend a minimum of 3/5 locations. 警报位置阈值和测试位置数目之间的最佳关系是警报位置阈值 = 测试位置数 - 2,至少有 5 个测试位置 。The optimal relationship between alert location threshold and the number of test locations is alert location threshold = number of test locations - 2, with a minimum of five test locations.

查看可用性测试结果See your availability test results

可用性测试结果可以使用折线图和散点图的视图进行可视化。Availability test results can be visualized with both line and scatter plot views.

几分钟之后,单击“刷新” 即可查看测试结果。After a few minutes, click Refresh to see your test results.

屏幕截图显示 "刷新" 按钮突出显示的 "可用性" 页。

散点图视图显示其中有诊断测试步骤详细信息的测试结果示例。The scatterplot view shows samples of the test results that have diagnostic test-step detail in them. 测试引擎存储已失败的测试的诊断详细信息。The test engine stores diagnostic detail for tests that have failures. 对于成功的测试,将存储执行子集的诊断详细信息。For successful tests, diagnostic details are stored for a subset of the executions. 将鼠标悬停在任何绿点/红点上,可查看测试、测试名称和位置。Hover over any of the green/red dots to see the test, test name, and location.


选择特定测试、位置或减少时间段,可查看围绕感兴趣的时间段的更多结果。Select a particular test, location, or reduce the time period to see more results around the time period of interest. 使用搜索资源管理器以查看所有执行结果,或者使用分析查询以针对此数据运行自定义报告。Use Search Explorer to see results from all executions, or use Analytics queries to run custom reports on this data.

检查和编辑测试Inspect and edit tests

若要编辑、临时禁用或删除某个测试,请单击测试名称旁边的省略号。To edit, temporarily disable, or delete a test click the ellipses next to a test name. 进行更改后,将配置更改传播到所有测试代码最多可能需要 20 分钟。It may take up to 20 minutes for configuration changes to propagate to all test agents after a change is made.


对服务执行维护时,可能需要禁用可用性测试或与这些测试关联的警报规则。You might want to disable availability tests or the alert rules associated with them while you are performing maintenance on your service.

如果看到失败If you see failures

单击红点。Click a red dot.


从可用性测试结果中,可以看到所有组件的事务详细信息。From an availability test result, you can see the transaction details across all components. 在此门户中,可以:Here you can:

  • 检查从服务器收到的响应。Inspect the response received from your server.
  • 使用在处理失败的可用性测试时收集的相关服务器端遥测数据进行故障诊断。Diagnose failure with correlated server-side telemetry collected while processing the failed availability test.
  • 在 Git 或 Azure Boards 中记录问题或工作项以跟踪问题。Log an issue or work item in Git or Azure Boards to track the problem. Bug 中将包含转至此事件的链接。The bug will contain a link to this event.
  • 在 Visual Studio 中打开 Web 测试结果。Open the web test result in Visual Studio.

此处详细了解端到端事务诊断体验。Learn more about the end to end transaction diagnostics experience here.

单击异常行可查看导致综合可用性测试失败的服务器端异常的详细信息。Click on the exception row to see the details of the server-side exception that caused the synthetic availability test to fail. 还可以获取调试快照,进行更丰富的代码级诊断。You can also get the debug snapshot for richer code level diagnostics.


除了原始结果外,还可以在指标资源管理器中查看两个关键的可用性指标:In addition to the raw results, you can also view two key Availability metrics in Metrics Explorer:

  1. 可用性:已成功的测试占执行的所有测试的百分比。Availability: Percentage of the tests that were successful, across all test executions.
  2. 测试持续时间:执行的所有测试的平均测试持续时间。Test Duration: Average test duration across all test executions.



专用故障排除文章Dedicated troubleshooting article.

后续步骤Next steps