Skip to content

Instantly share code, notes, and snippets.

@kerslake
Last active August 29, 2015 14:16
Show Gist options
  • Save kerslake/e19253e093cbb4876608 to your computer and use it in GitHub Desktop.
Save kerslake/e19253e093cbb4876608 to your computer and use it in GitHub Desktop.
[Reflection.Assembly]::LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime")
$roleInstanceId = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id
$appName = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::GetConfigurationSettingValue("NewRelic.AppName")
$filename = "${env:RoleRoot}\approot\WorkerRoleWithNewRelic.dll.config"
$xml = New-Object XML
if (Test-Path ($filename))
{
$xml.Load($filename)
$appSettings = $xml.configuration.appSettings
$appNameSetting = $xml.CreateElement("add")
$appNameSetting.SetAttribute("key", "NewRelic.AppName")
$appNameSetting.SetAttribute("value", $appName)
$appSettings.AppendChild($appNameSetting);
$xml.Save($filename)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment