Azure Website - Web.config transform fails "No element in the source document matches /configuration/system.identityModel/identityConfiguration"
Asked Answered
E

5

13

Our ASP.NET Web Api project has two deployment configurations (.pubxml):

  1. Web deployment directly to Azure Websites.
  2. Package deployment to a local Zip file.

The Web deployment (1) works just fine. The Package deployment to a zip is failing with the following errors:

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

Looking at the verbose logs, I can see it's failing during the Web.config transform.

        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.

What additional build information do I need to configure to get the Zip deployment past these errors? It works just fine if I do a direct web deployment.

Eindhoven answered 9/2, 2015 at 17:54 Comment(0)
N
27

Check your publish settings to see if you have EnableADPublish set to true. That was my problem (I was configuring Azure AD Auth through other means), so I just set it to false and everything worked great.

<EnableADPublish>false</EnableADPublish>

Cheers, Jeff

Nicknickel answered 30/3, 2015 at 17:30 Comment(2)
This worked for me as well, but do we have any idea why?Consultation
Same. No idea what EnableADPublish is, but worked for me too.Dentifrice
P
3

If you are using the publish wizard, make sure that "Enable Organizational Authentication" is unchecked**. This fixed it for me.

enter image description here

Prizefight answered 18/8, 2016 at 19:53 Comment(0)
S
2

I added the below configuration explicitly:

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

It is able to create the package finally!

Schuster answered 5/10, 2016 at 6:52 Comment(0)
L
0

You are missing the system.identityModel elements in your configuration for AD integration. If you want to integrate with the azure AD, you need to enable Windows Identity Foundation (WIF) options in your configuration.

<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>
Legate answered 31/5, 2016 at 16:19 Comment(0)
F
0

I know this is pretty old, but I just had this problem and the only thing that solved it for me was to re-download the publish profile from the Azure Web App Overview blade's "Get Publish Profile" button. Then I had to import it into the solution.

Hope that helps someone!

Fewell answered 17/10, 2017 at 16:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.