Azure网站 - Web.config转换失败“源文档中没有元素匹配/configuration/system.identityModel/identityConfiguration”

时间:2015-02-09 17:54:21

标签: asp.net azure web.config-transform

我们的ASP.NET Web Api项目有两个部署配置(.pubxml):

  1. 直接向Azure网站部署Web。
  2. 将部署包部署到本地Zip文件。
  3. Web部署(1)工作得很好。 对zip的Package部署失败,并出现以下错误:

    Warning 3   No element in the source document matches '/configuration/system.identityModel'     20  10  MyWebProject
    Error   4   No element in the source document matches '/configuration/system.identityModel/identityConfiguration'       21  10  MyWebProject
    

    查看详细日志,我可以看到它在Web.config转换过程中失败。

            ParameterizeTransformXml:   No element in the source document matches '/configuration/appSettings/add[@key='ida:AudienceUri']'
            ParameterizeTransformXml:   Not executing SetTokenizedAttributes (transform line 7, 9)
            ParameterizeTransformXml:   No element in the source document matches '/configuration/appSettings/add[@key='ida:Realm']'
            ParameterizeTransformXml:   Not executing SetTokenizedAttributes (transform line 10, 9)
            ParameterizeTransformXml:   No element in the source document matches '/configuration/appSettings/add[@key='ida:FederationMetadataLocation']'
            ParameterizeTransformXml:   Not executing SetTokenizedAttributes (transform line 13, 9)
     Warning : No element in the source document matches '/configuration/system.identityModel'
            ParameterizeTransformXml:   Not executing RemoveAll (transform line 24, 14)
     Error : No element in the source document matches '/configuration/system.identityModel/identityConfiguration'
            ParameterizeTransformXml:   Not executing Insert (transform line 27, 9)
            ParameterizeTransformXml:   No element in the source document matches '/configuration/system.identityModel'
            ParameterizeTransformXml:   Not executing SetTokenizedAttributes (transform line 33, 9)
            ParameterizeTransformXml:   No element in the source document matches '/configuration/system.identityModel.services'
            ParameterizeTransformXml:   Not executing SetTokenizedAttributes (transform line 42, 9)
            ParameterizeTransformXml:   No element in the source document matches '/configuration/system.identityModel.services'
            ParameterizeTransformXml:   Not executing SetTokenizedAttributes (transform line 45, 9)
            ParameterizeTransformXml: Transformation failed
            Done executing task "ParameterizeTransformXml" -- FAILED.
            Done building target "_TransformWebConfigForAzureAuthenticationCore" in project "MyWebProject.csproj" -- FAILED.
    Done building project "MyWebProject.csproj" -- FAILED.
    

    我需要配置哪些额外的构建信息才能使Zip部署超过这些错误?如果我进行直接Web部署,它可以正常工作。

5 个答案:

答案 0 :(得分:26)

检查您的发布设置,看看您是否将EnableADPublish设置为true。这是我的问题(我通过其他方式配置Azure AD Auth),所以我只是把它设置为false,一切都很好。

<EnableADPublish>false</EnableADPublish>

干杯, 杰夫

答案 1 :(得分:3)

如果您使用的是发布向导,请确保未选中“启用组织身份验证”**。这为我修好了。

enter image description here

答案 2 :(得分:2)

我明确添加了以下配置:

<system.identityModel>
    <identityConfiguration>
      <audienceUris>        
      </audienceUris>
    </identityConfiguration>
</system.identityModel>

最终能够创建包!

答案 3 :(得分:0)

您缺少配置中用于AD集成的system.identityModel元素。如果要与azure AD集成,则需要在配置中enable Windows Identity Foundation (WIF) options

<configuration>
  <configSections>
    <!--WIF 4.5 sections -->
    <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  </configSections>

  ...

  <system.identityModel>
    <identityConfiguration>
      <audienceUris>
        <add value="http://localhost/WebApplication1/" />
      </audienceUris>
      <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
        <trustedIssuers>
          <add thumbprint="313D3B … 9106A9EC" name="SelfSTS" />
        </trustedIssuers>
      </issuerNameRegistry>
      <certificateValidation certificateValidationMode="None"/>
    </identityConfiguration>
  </system.identityModel>

  ...

</configuration>

答案 4 :(得分:0)

我知道这已经很老了,但我遇到了这个问题,唯一解决它的问题是从Azure Web App概述刀片的“获取发布配置文件”按钮重新下载发布配置文件。然后我不得不将其导入解决方案。

希望能帮助别人!