# APM .NET Agent Public API Configuration

**URL:** <https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [May 17, 2019, 8:03pm UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649 "2019-05-17T20:03:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kburge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kburge/32/45388_2.png) [@kburge](https://discuss.elastic.co/u/kburge)\
**Post date:** [May 17, 2019, 8:03pm UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/1 "2019-05-17T20:03:16Z")

</div>

How do we specify the ServerUrls, ServiceName, etc. when using the Public API of the APM .NET Agent? I need to change from the default [http://localhost:8200](http://localhost:8200) to a different URL but I am unable to find where it needs to be set.

The application I am trying to instrument manually is a web application on .NET Framework 4.5. I have a few console applications on .NET Framework 4+ that I am planning to do as well if I can figure out how to set the configurations properly.

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [May 17, 2019, 8:15pm UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/2 "2019-05-17T20:15:22Z")

</div>

hi @kburge  
[https://www.elastic.co/guide/en/apm/agent/dotnet/current/config-reporter.html](https://www.elastic.co/guide/en/apm/agent/dotnet/current/config-reporter.html)

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 17, 2019, 8:19pm UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/3 "2019-05-17T20:19:01Z")

</div>

Hi @kburge,

thanks @nugusbayevkk for the link, that's exactly the part of the documentation that contains the answer.

So the default way to configure the agent is to use environment variables, that works with basically every setup (then we also have `IConfiguration` for [ASP.NET](http://ASP.NET) Core, but that's not the topic here...). For changing the URL of the server the `ELASTIC_APM_SERVER_URLS` environment variable should be used.

---

<div class="post-metadata">

**Author:** ![kburge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kburge/32/45388_2.png) [@kburge](https://discuss.elastic.co/u/kburge)\
**Post date:** [May 17, 2019, 8:46pm UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/4 "2019-05-17T20:46:46Z")

</div>

Awesome! Thank you.

I wasn't sure about how the environment variables work in C# so for anyone else that comes across this you just do this at the beginning of your code:

Environment.SetEnvironmentVariable("ELASTIC\_APM\_SERVER\_URLS", "[http://your-apm-server:8200](http://your-apm-server:8200)");  
Environment.SetEnvironmentVariable("ELASTIC\_APM\_SERVICE\_NAME", "Your Service Name");

---

<div class="post-metadata">

**Author:** ![NeoX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neox/32/47249_2.png) [@NeoX](https://discuss.elastic.co/u/NeoX)\
**Post date:** [June 5, 2019, 9:35am UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/5 "2019-06-05T09:35:23Z")

</div>

Given the server URL can be configured for [ASP.NET](http://ASP.NET) Core using `IConfiguration` (by setting `ElasticApm.ServerUrls` in a settings JSON file), can a similar configuration not also be done for [ASP.NET](http://ASP.NET) Full Framework so that `ELASTIC_APM_SERVER_URLS` doesn't need to be set? I can't see in `Elastic.Apm.AspNetFullFramework` if it's possible.

---

<div class="post-metadata">

**Author:** ![Sergey\_Kleyman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergey_kleyman/32/39333_2.png) [@Sergey\_Kleyman](https://discuss.elastic.co/u/Sergey_Kleyman)\
**Post date:** [June 6, 2019, 9:57am UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/6 "2019-06-06T09:57:31Z")

</div>

Do you mean setting `ElasticApm.ServerUrls` somewhere in `web.config` or something else?

In any case you are welcome to open an enhancement issue at the [Github repo](https://github.com/elastic/apm-agent-dotnet/).

---

<div class="post-metadata">

**Author:** ![NeoX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neox/32/47249_2.png) [@NeoX](https://discuss.elastic.co/u/NeoX)\
**Post date:** [June 12, 2019, 2:31pm UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/7 "2019-06-12T14:31:33Z")

</div>

Yes, exactly. I've added an [issue](https://github.com/elastic/apm-agent-dotnet/issues/275) for this.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 3, 2019, 10:31am UTC](https://discuss.elastic.co/t/apm-net-agent-public-api-configuration/181649/8 "2019-07-03T10:31:34Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
