HTML escape characters in Azure app settings

Windows applications can make use of XML nodes in appSettings to pass configuration information into a program.  Because the app.config (or web.config) file is XML some characters need to be escaped so that they are not improperly parsed as part of the XML markup.

In a recent project I ran into a problem with the following setting:

John Doe <address@foo.com>

This represented the email address from which email was to be sent on behalf of the application.  The less than and greater than characters needed to be escaped:

John Doe &lt;address@foo.com&gt;

So now the app ran fine on my development box with the escaped characters properly converted to ‘<‘ and ‘>’ respectively.  Upload the app to an Azure web job and configure the app settings with the same value as above and this results in …..  errors.  The email program complained about invalid semi-colons.

Note that the Azure app settings values are not represented in an XML file and thus should not be HTML escaped.  Changing the Azure app setting to the original value:

John Doe <address@foo.com>

and the email code now works as expected.

This entry was posted in Programming and tagged . Bookmark the permalink.

One Response to HTML escape characters in Azure app settings

  1. Frank says:

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *