The easiest way is to use config transformations as bhavesh said, though the web.config he posted is outdated since NET 4.5.
You can have your local development configuration in web.config
, your cloud development configuration in web.Debug.config
and your production configruation in web.Release.config
.
Here's an example web.Debug.config (only relevant parts):
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add xdt:Transform="RemoveAll" />
<add value="http://myinstance.cloudapp.net/" xdt:Transform="Insert" />
</audienceUris>
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration >
<cookieHandler requireSsl="false" />
<wsFederation passiveRedirectEnabled="true" issuer="https://mynamespace.accesscontrol.windows.net/v2/wsfederation" realm="http://myinstance.cloudapp.net/" reply="http://myinstance.cloudapp.net/" requireHttps="false" xdt:Transform="Replace"/>
</federationConfiguration>
</system.identityModel.services>
Now all that's left to do is to configure a Relying Party for each configuration in your ACS portal.
You can actually configure a single RP for all 3 configurations, but the only way to achieve this is programmatically using the Service Management API since the portal only allows you to configure one Realm / Return URL value per Relying Party.
Note that if you decide to do this, you'll have to set the return url in your web.config (reply
attribute) otherwise ACS would always overwrite it with the first configured return url (the one you see in the portal).