Azure云服务 - XML规范无效
问题描述:
我在云服务中有两个Web角色,一个在外部公开,一个在内部使用。外部Web角色具有一个MVC Web应用程序,该应用程序必须连接到将具有Web API的内部Web角色。我有我的Azure云服务的以下服务定义。Azure云服务 - XML规范无效
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureWeb_ExternalCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="ExternalWebApplication" vmsize="A6">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
<Setting name="ServiceBaseURL" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
</WebRole>
<WebRole name="InternalWebAPI" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint2" endpointName="Endpoint2" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InternalEndpoint name="Endpoint2" protocol="http" port="8080" />
</Endpoints>
</WebRole>
<NetworkTrafficRules>
<OnlyAllowTrafficTo>
<Destinations>
<RoleEndpoint roleName="InternalWebAPI" endpointName="Endpoint2"/>
</Destinations>
<WhenSource matches="AnyRule">
<FromRole roleName="ExternalWebApplication"/>
</WhenSource>
<AllowAllTraffic/>
</OnlyAllowTrafficTo>
</NetworkTrafficRules>
</ServiceDefinition>
但是,当我尝试构建时,出现以下错误。
的XML规范无效:元素 'OnlyAllowTrafficTo' 在命名空间 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition' 在命名空间 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition' 无效子元素 'AllowAllTraffic'
答
按照ServiceDefinitionSchema(我的位于%ProgramFiles%\ Microsoft SDKs \ Azure.NET SDK \ v2.8 \ schemas),AllowAllTraffic元素必须位于WhenSource元素之前。