---
title: Tricks for Configuring New Relic for .NET Core
description: Discover how to configure New Relic for a .NET Core 2 Web API on Azure Web App for Containers.
image: https://blog.avenuecode.com/hubfs/13-1.jpg
---

[AvenueCode.com](https://avenuecode.com) [News](https://avenuecode.com/news) [Contact](https://avenuecode.com/contact)

[![Avenue Code Snippets Logo](https://blog.avenuecode.com/hubfs/Avenue%20Code%20New%20Logos%20-%202023/AC-Snippets---Black.png)](https://blog.avenuecode.com/?hsLang=en-us) *menu*

- Technology
  
  [Cloud](https://blog.avenuecode.com/blog/topic/cloud?hsLang=en-us) [Delivery Infrastructure](https://blog.avenuecode.com/blog/topic/delivery-infrastructure?hsLang=en-us) [Web Experience](https://blog.avenuecode.com/blog/topic/web-experience?hsLang=en-us) [Agile Mindset](https://blog.avenuecode.com/blog/topic/agile-mindset?hsLang=en-us) [Quality First](https://blog.avenuecode.com/blog/topic/quality-first?hsLang=en-us)
  
  [Design](https://blog.avenuecode.com/blog/topic/design?hsLang=en-us) [Solution Architecture](https://blog.avenuecode.com/blog/topic/solution-architecture?hsLang=en-us) [Data & ML](https://blog.avenuecode.com/blog/topic/data-and-machine-learning?hsLang=en-us) [Mobile Experience](https://blog.avenuecode.com/blog/topic/mobile-experience?hsLang=en-us)
- [Whitepapers](https://blog.avenuecode.com/blog/topic/whitepapers?hsLang=en-us)
- [Spotlight](https://blog.avenuecode.com/blog/topic/spotlight?hsLang=en-us)
- [Extraordinary Women in Tech](https://blog.avenuecode.com/blog/topic/extraordinary-women-in-tech?hsLang=en-us)
- [Avenue Code Culture](https://blog.avenuecode.com/blog/topic/avenue-code-culture?hsLang=en-us)

- [Cloud](https://blog.avenuecode.com/blog/topic/cloud?hsLang=en-us)
- [Design](https://blog.avenuecode.com/blog/topic/design?hsLang=en-us)
- [Delivery Infrastructure](https://blog.avenuecode.com/blog/topic/delivery-infrastructure?hsLang=en-us)
- [Solution Architecture](https://blog.avenuecode.com/blog/topic/solution-architecture?hsLang=en-us)
- [Web Experience](https://blog.avenuecode.com/blog/topic/web-experience?hsLang=en-us)
- [Data & ML](https://blog.avenuecode.com/blog/topic/data-and-machine-learning?hsLang=en-us)
- [Agile Mindset](https://blog.avenuecode.com/blog/topic/agile-mindset?hsLang=en-us)
- [Mobile Experience](https://blog.avenuecode.com/blog/topic/mobile-experience?hsLang=en-us)
- [Quality First](https://blog.avenuecode.com/blog/topic/quality-first?hsLang=en-us)
- [Whitepapers](https://blog.avenuecode.com/blog/topic/whitepapers?hsLang=en-us)
- [Spotlight](https://blog.avenuecode.com/blog/topic/spotlight?hsLang=en-us)
- [Extraordinary Women in Tech](https://blog.avenuecode.com/blog/topic/extraordinary-women-in-tech?hsLang=en-us)
- [Avenue Code Culture](https://blog.avenuecode.com/blog/topic/avenue-code-culture?hsLang=en-us)

# [Tricks for Configuring New Relic for .NET Core](https://blog.avenuecode.com/tricks-for-configuring-new-relic-for-.net-core)

- [Tweet](https://twitter.com/share)

*perm\_identity* [Rafael Romão](https://blog.avenuecode.com/tricks-for-configuring-new-relic-for-.net-core/author/rafael-rom%C3%A3o?hsLang=en-us)

*schedule* 2/21/18 5:00 PM

New Relic is a performance monitoring tool well known by the microservices community. It supports a lot of platforms, but it's support for .NET Core is still recent. In this post, I'll walk you through how to configure a .NET Core 2 Web API to send metrics to New Relic from a Docker container inside an Azure Web App for Containers.

To follow this tutorial, you'll need a [New Relic](https://newrelic.com/) account and a valid New Relic license key. You will also need [Docker](https://www.docker.com/) and [.NET Core 2](https://dot.net) configured and running in you development machine, a [Docker Hub](https://hub.docker.com) account, and an [Azure](https://portal.azure.com) subscription.

### Creating the Web API

Let's start by creating a new Web API. In this demo, I will name  our API *baseline-demo*.

In the *baseline-demo* project folder, type:

```
dotnet new api
```

This command will scaffold our API.

Now, let's add [Swagger](https://swagger.io/) to this API to give us a UI to test it:

```
dotnet add package Swashbuckle.AspNetCoredotnet add package Swashbuckle.AspNetCore.SwaggerUI
```

Next, change your Startup.cs file to set up the Swashbuckle middleware:

```
public class Startup{    public Startup(IConfiguration configuration)    {        Configuration = configuration;    }    public IConfiguration Configuration { get; }    public void ConfigureServices(IServiceCollection services)    {        services.AddMvc();        services.AddSwaggerGen(c =>        {            c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });        });    }    public void Configure(IApplicationBuilder app, IHostingEnvironment env)    {        if (env.IsDevelopment())        {            app.UseDeveloperExceptionPage();        }        app.UseMvc();        app.UseSwagger();        app.UseSwaggerUI(c =>        {            c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");        });    }}
```

Run the API and test it using the Swagger UI:

```
dotnet run
```

```
http://localhost:5000/swagger
```

### Adding Docker and New Relic

Now let's look at how to add Docker and New Relic. First, download the New Relic .NET Core agent. In this demo, we'll use the Debian version.

```
http://download.newrelic.com/dot_net_agent/core_20/current
```

Copy the file *newrelic-netcore20-agent\*.deb* to the folder *baseline-demo/newrelic*.

In the folder *baseline-demo,* create a DOCKERFILE with the following content:

```
FROM microsoft/dotnet:2.0.0-sdk-2.0.2-stretchENV CORECLR_ENABLE_PROFILING="1" \CORECLR_PROFILER="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" \CORECLR_NEWRELIC_HOME="/usr/local/newrelic-netcore20-agent" \CORECLR_PROFILER_PATH="/usr/local/newrelic-netcore20-agent/libNewRelicProfiler.so" \NEW_RELIC_LICENSE_KEY="YOUR_LICENSE_KEY" \NEW_RELIC_APP_NAME="baseline-demo"WORKDIR /appARG runtimeIdentifier=debian-x64ARG files=./bin/Release/netcoreapp2.0/$runtimeIdentifier/publishCOPY $files ./appcodeARG NewRelic=./newrelicCOPY $NewRelic ./newrelicRUN dpkg -i ./newrelic/newrelic-netcore20-agent*.debENV ASPNETCORE_URLS http://+:5000EXPOSE 5000WORKDIR /app/appcodeENTRYPOINT ["dotnet", "./baseline-demo.dll"]
```

Now, publish your API targeting *debian-x64*:

```
dotnet publish -c Release -r debian-x64
```

And build a docker image with the published content:

```
docker build . -t baseline-demo
```

Now, simply run your container:

```
docker run -itp 5000:5000 -rm baseline-demo
```

Go to [Swagger](http://localhost:5000/swagger) and make some GET requests.

In a few minutes, you should see some metrics under your account in [New Relic](https://rpm.newrelic.com). They will appear as follows:

![Print screen from New Relic RPM showing some transactions from the baseline-demo application.](https://blog.avenuecode.com/hs-fs/hubfs/baseline-demo-1.png?width=912&name=baseline-demo-1.png "Print screen from New Relic RPM showing some transactions from the baseline-demo application.")

### Publishing the Container to Docker Hub

On your Docker Hub portal, create a new repository and give it the same name as your Docker image.

Then, tag the local image to match this Docker Hub repository, like this:

```
docker tag baseline-demo rafaelromao/baseline-demo
```

Log in to your Docker Hub account and push the local image to the repository:

```
docker logindocker push rafaelromao/baseline-demo:latest
```

Now your image will be available for use in an Azure Web App for Containers.

### Running Your Web API Container on Azure

 In the Azure Portal, click *New* and search for "Web App for Containers." Follow the creation wizard and inform your container settings when requested:

![Screenshot of the Azure Portal showing the container settings for a Web App for Containers](https://blog.avenuecode.com/hs-fs/hubfs/Web%20App%20For%20Containers-1.png?width=912&name=Web%20App%20For%20Containers-1.png "Screenshot of the Azure Portal showing the container settings for a Web App for Containers")

Finish the creation and access the */swagger* endpoint in the URL provided for your app and make some test requests.

```
https://baseline-demo.azurewebsites.net/swagger
```

Now go to [New Relic](https://rpm.newrelic.com) again to see the metrics collected from your API, which is now running on Azure.

### Conclusion

This short tutorial shows one of the many options available for configuring New Relic for a .NET Core 2 Web API. For more information, check out [New Relic's documentation](https://docs.newrelic.com/docs/agents/net-agent/installation/install-net-core-20-agent-docker#linux). Don't forget to comment below to tell us what you think about the amazing tools we used in this demo!

---

[![Twitter Icon](https://blog.avenuecode.com/hubfs/Images/Blog/twitter.png)](http://twitter.com/rmromao) [![LinkedIn Icon](https://blog.avenuecode.com/hubfs/Images/Blog/linkedin.png)](http://linkedin.com/in/rafaelromao)

### Author

# Rafael Romão

 Rafael Romão is a Software Engineer at Avenue Code. He has studied software development since 1998 and has worked as a software developer since 2002. His main areas of interest are software architecture and design, as well as the development of highly productive teams.

---

### Related Posts

### Asymmetric Cryptography

[READ MORE](https://blog.avenuecode.com/asymmetric-cryptography?hsLang=en-us)

### Improving the developer experience when documenting

[READ MORE](https://blog.avenuecode.com/improving-the-developer-experience?hsLang=en-us)

### How to Run Rust from Python

[READ MORE](https://blog.avenuecode.com/how-to-run-rust-from-python?hsLang=en-us)

### How to Create a Tic-Tac-Toe Board Using React.js

[READ MORE](https://blog.avenuecode.com/how-to-create-a-tic-tac-toe-board-using-react.js?hsLang=en-us)

### Leave a Comment!

### Avenue Code Social

[![Facebook Icon](https://blog.avenuecode.com/hubfs/Images/Blog/facebook.png?t=1486470796564)](https://www.facebook.com/avenuecode)

[![Twitter Icon](https://blog.avenuecode.com/hubfs/Images/Blog/twitter.png?t=1486470796842)](https://twitter.com/AvenueCode)

[![LinkedIn Icon](https://blog.avenuecode.com/hubfs/Images/Blog/linkedin.png?t=1486470796556)](https://www.linkedin.com/company/avenue-code)

### Newsletter

Want to stay on top of all tips and news from Avenue Code?

### Popular Snippets

![Primary Logo AvenueCode Inverted.png](https://blog.avenuecode.com/hs-fs/hubfs/Images/Logos/Primary%20Logo%20AvenueCode%20Inverted.png?width=1104&name=Primary%20Logo%20AvenueCode%20Inverted.png "Primary Logo AvenueCode Inverted.png")

### About Us

- [Who We Are](https://www.avenuecode.com/who-we-are)
- [What We Do](https://www.avenuecode.com/what-we-do)
- [Portfolio](https://www.avenuecode.com/portfolio)
- [Partners](https://www.avenuecode.com/partners)
- [News](https://www.avenuecode.com/news)
- [Events](https://www.avenuecode.com/events)
- [Blog](https://blog.avenuecode.com/)
- [Contact](https://www.avenuecode.com/contact)

### Our Offices

San Francisco

[+1 415 766 4178](tel:+553125161448) [ac.inquiries@avenuecode.com](mailto:brazil.info@avenuecode.com)

Belo Horizonte

[+55 31 2516 1448](tel:+553125161448) [brazil.info@avenuecode.com](mailto:brazil.info@avenuecode.com)

São Paulo

[+55 11 3205 3232](tel:+553125161448) [brazil.info@avenuecode.com](mailto:brazil.info@avenuecode.com)

### We're Hiring!

- [Belo Horizonte](https://www.avenuecode.com/who-we-are)
- [New York](https://www.avenuecode.com/what-we-do)
- [San Francisco](https://www.avenuecode.com/portfolio)
- [São Paulo](https://www.avenuecode.com/partners)

---

©2015 - 2017 Avenue Code

[![Facebook Icon](https://blog.avenuecode.com/hubfs/Images/Icons/facebook-2.png)](https://www.facebook.com/avenuecode) [![Twitter Icon](https://blog.avenuecode.com/hubfs/Images/Icons/twitter-2.png)](https://twitter.com/AvenueCode) [![LinkedIn Icon](https://blog.avenuecode.com/hubfs/Images/Icons/linkedin-2.png)](https://www.linkedin.com/company/avenue-code) [![Glassdoor Icon](https://blog.avenuecode.com/hubfs/Images/Icons/glassdoor-icon-1.png)](https://www.glassdoor.com/Overview/Working-at-Avenue-Code-EI_IE456173.11,22.htm) [![YouTube Icon](https://blog.avenuecode.com/hubfs/Images/Icons/youtube-2.png)](https://www.youtube.com/user/AvenueCodePlay)

Please enable JavaScript to view the [comments powered by Disqus.](http://disqus.com/?ref_noscript)

© 2026 Avenue Code

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Rafael Romão",
    "url" : "https://blog.avenuecode.com/author/rafael-romão"
  },
  "datePublished" : "2018-02-21T20:00:00.000Z",
  "headline" : "Tricks for Configuring New Relic for .NET Core",
  "image" : [ "https://blog.avenuecode.com/hubfs/13-1.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.avenuecode.com/tricks-for-configuring-new-relic-for-.net-core",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.avenuecode.com/hubfs/Avenue%20Code%20New%20Logos%20-%202023/Avenue%20Code-primary%20versions_LOGO%20HORIZONTAL%20group%201-7.png"
    },
    "name" : "Avenue Code"
  }
}
```