Azure云服务 - XML规范无效

时间:2016-01-21 16:02:43

标签: asp.net-mvc azure azure-web-roles azure-cloud-services

我在云服务中有两个Web角色,一个用于在外部公开,一个用于内部用途。外部Web角色具有MVC Web应用程序,该应用程序必须连接到具有Web API的内部Web角色。我有Azure Cloud服务的以下服务定义。

<?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'   在命名空间中具有无效的子元素“AllowAllTraffic”   'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'

1 个答案:

答案 0 :(得分:0)

根据ServiceDefinitionSchema(我的位于%ProgramFiles%\ Microsoft SDKs \ Azure.NET SDK \ v2.8 \ schemas),AllowAllTraffic元素必须位于WhenSource元素之前。