LoadBalancerProbes 元素仅在 SDK 的 1.7 版(或更高版本)中受支持。现在,棘手的部分是您需要在定义 Web/Worker 角色之前添加它。所以像这样:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WindowsAzure6" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-10.1.8">
<LoadBalancerProbes>
<LoadBalancerProbe name="MyProbe" protocol="http" intervalInSeconds="300" path="/something.aspx" port="80" timeoutInSeconds="30" />
</LoadBalancerProbes>
<WebRole name="WebRole1" vmsize="Small">
...
</WebRole>
</ServiceDefinition>
如果在定义 Web/Worker 角色之后添加它,您将在 Visual Studio 中收到“无效的子元素”错误:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WindowsAzure6" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-10.1.8">
<WebRole name="WebRole1" vmsize="Small">
...
</WebRole>
<LoadBalancerProbes>
<LoadBalancerProbe name="MyProbe" protocol="http" intervalInSeconds="300" path="/something.aspx" port="80" timeoutInSeconds="30" />
</LoadBalancerProbes>
</ServiceDefinition>