;

Configuring newrelic In Azure CloudServices

Posted : Wednesday, 20 August 2014 21:58:00

With truRating so close to launch we have just put in place our monitoring service – we looked at the options and newrelic was the stand-out choice. One problem we needed to solve that wasn’t supported natively by newrelic was the ability to dynamically configure application name at deploy time! – the basic portal new relic screen looks as follows showing a list of all Applications.

 

image

 

I have none :-(

IIS Application names (CloudService web roles) are registered via an appsetting:

  <appSettings>

    <add key="NewRelic.AppName" value="LOCAL_APP" />

  </appSettings>

if you want to “promote” this to a cloud setting its bit fiddly as you need to get the cloud package which contains the transforms to set the web.config value. To do this you need to alter any ServiceName.*.cscfg files (the service configuration file for each env) and the ServiceName.csdef (the service definition file) files manually. It looks like Visual Studio doesn’t reliably support much beyond vanilla configuration with these projects but these customisations is fairly niche so I wouldn’t expect it to.

 

To configure this application name to be set from cloud configuration  setting is a three step process:

First the Service Definition file (.csdef).

After installing the new relic nuget package the service definition file should include a startup task for each role in the cloud project:

    5     <Startup>

    6       <Task commandLine="newrelic.cmd" executionContext="elevated" taskType="simple">

    7         <Environment>

    8           <Variable name="EMULATED">

    9             <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />

   10           </Variable>

   11           <Variable name="IsWorkerRole" value="false" />

   12           <Variable name="LICENSE_KEY">

   13             <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='NewRelic.LicenseKey']/@value" />

   14           </Variable>

   15         </Environment>

   16       </Task>

   17     </Startup>

This startup task will execute as the role initializes and will execute the specified newrelic.cmd file using supplied environment variables. (more on that later) .

Define another environment variable that will be declared based on a cloud configuration value:

Post a comment Sharespacer Tagged: ASP.NET, Azure
  • (This will not appear on the site)