To have New Relic working for a .NET app hosted on Azure's App Services, I needed New Relic's .NET agent installed in 1 of 3 ways.
- Manual installation via NuGet
- Extension installation via the SCM website
- Extension installation via the Azure Portal
Initially I had it installed via the Azure Portal (method 3), which seemed fine but to give us better flexibility in having a "clean" deployment by setting the
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer> flag on my publishing profile. This meant that Web Deploy was trying to "remove" the extra files/folder ( the
newrelic folder in this case under
A solution for me was to change the way New Relic's .NET agent was installed from method 3 to 1. After running
Install-Package NewRelic.Azure.WebSites from the Package Manager Console, I noticed that it had also installed New Relic's dll's into a folder named
newrelic at the website's root which seemed to be a little problematic.
I wanted to have this folder not checked into version control and was hoping my CI server would repopulate this folder after running
nuget restore mysolution.sln but I had noticed that it didn't actually repopulate
newrelic folder at the website's root like it did with the
Install-Package NewRelic.Azure.WebSites. So as a workaround to this issue, I had to check the entire
newrelic directory into version control.
I ran into another problem with deploying the application
F:\bamboo-home\xml-data\build-dir\917505-1015809\myproject\src\Web\Api\myproject.csproj" (default target) (1) ->(MSDeployPublish target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4288,5): msdeploy error ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER: Web deployment task failed. (Unable to perform the operation ("Delete File") for the specified directory ("D:\home\site\wwwroot\newrelic\Extensions\JetBrains.Annotations.dll"). This can occur if the server administrator has not authorized this operation for the user credentials you are using.
I tried to manually remove the directory first via the Kudu's Console but it seemed like even logging into the Kudu with administrator permissions didn't allow me to remove the directory.
Turns out that New Relic's profiler dlls are locked. So the solution was to
- Stop your web app to release the .dll file.
- Allow the update to proceed.
- Once the deploy is complete, restart the instance.
Wasn't easy but got there in the end.