# How to setup Opbeans-dotnet for Elastic APM

**URL:** <https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038>\
**Category:** APM\
**Tags:** elastic-stack-monitoring, dotnet\
**Created:** [September 9, 2020, 4:02pm UTC](https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038 "2020-09-09T16:02:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckough](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ckough/32/61892_2.png) [@ckough](https://discuss.elastic.co/u/ckough)\
**Post date:** [September 9, 2020, 4:02pm UTC](https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038/1 "2020-09-09T16:02:54Z")

</div>

Hi there,

I'm running ELK 7.7 with APM 7.7.

I have successfully setup Opbeans-java for APM monitoring.

I have also downloaded and run the Opbeans-dotnet application.

How do i setup APM .net agent for it?

I have run the following:

```auto
Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.208 -Force
Get-PackageSource

Name ProviderName IsTrusted Location
---- ------------ --------- --------
nuget.org NuGet False https://api.nuget.org/v3/index.json
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2

Set-PackageSource nuget.org -Trusted

Install-Package Elastic.Apm.AspNetCore -Version 1.6.1

Install-Package : A parameter cannot be found that matches parameter name 'Version'.
At line:1 char:40
+ Install-Package Elastic.Apm.AspNetCore -Version 1.6.1
+ ~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Install-Package], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Install-Package Elastic.Apm.AspNetCore
Install-Package : No match was found for the specified search criteria and package name 'Elastic.Apm.AspNetCore'. Try
Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Elastic.Apm.AspNetCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 -ProviderName NuGet
Install-Package : No match was found for the specified search criteria and package name 'Elastic.Apm.NetCoreAll'. Try
Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

```

How do I install the Elastic.Apm.AspNetCore package?

Thanks,  
ck

---

<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:** [September 9, 2020, 4:34pm UTC](https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038/2 "2020-09-09T16:34:14Z")

</div>

Hi @ckough,

just follow the [docs](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup.html#setup-asp-net-core) - Opbeans-dotnet is an [ASP.NET](http://ASP.NET) Core application, so turning on the agent is the same for it as turning it on to any other [ASP.NET](http://ASP.NET) Core app.

I suspect this is the missing part:

```auto
using Elastic.Apm.NetCoreAll;

public class Startup
{
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
    app.UseAllElasticApm(Configuration); //<- add this line, this activates the agent
    //…rest of the method
  }
  //…rest of the class
}

```

Alternatively you can also try our brand new no code change approach, which is currently in Beta:

> **[Release 1.7.0-beta1 · elastic/apm-agent-dotnet](https://github.com/elastic/apm-agent-dotnet/releases/tag/1.7.0-beta1)**
>
> Features
> 
> Loading agent during startup without any code change on .NET Core.
> 
> ElasticApmAgent\_1.7.0beta1.zip contains the agent distribution.
> Setup instructions and more info can be found here.

Documentation is here in the readme file: [https://github.com/elastic/apm-agent-dotnet/tree/master/src/ElasticApmStartupHook#how-to-use-it](https://github.com/elastic/apm-agent-dotnet/tree/master/src/ElasticApmStartupHook#how-to-use-it)

---

<div class="post-metadata">

**Author:** ![ckough](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ckough/32/61892_2.png) [@ckough](https://discuss.elastic.co/u/ckough)\
**Post date:** [September 10, 2020, 9:19am UTC](https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038/3 "2020-09-10T09:19:17Z")

</div>

Hi Greg,

Thanks for the reply.

My question is not so much on how to configure the agent as how to install it.

My issue is i can't seem to do the install-package command bc the package is not found.

I've used:  
Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 -ProviderName NuGet  
Install-Package Elastic.Apm.AspNetCore  
Install-Package Elastic.Apm.AspNetCore -Version 1.6.1

and the latter 2 tells me:  
No match was found for the specified search criteria and package name 'Elastic.Apm.AspNetCore'

So the question is still how do I set up the Elastic.Apm.AspNetCore package in Windows?

Thanks,  
ck

---

<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:** [September 10, 2020, 11:11am UTC](https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038/4 "2020-09-10T11:11:22Z")

</div>

The packages are NuGet packages, so all you need to do is to install the NuGet packages to the app.

Except if you go with the beta release I linked where you can attach the agent during startup as that doc states:

> Agent assemblies need to be loaded onto the disk where the traced .NET app is running. The agent with all the necessary files is currently distributed via GitHub on the [releases page](https://github.com/elastic/apm-agent-dotnet/releases) through a zip file (ElasticApmAgent\_[version].zip).

So in that case you'd download the `.zip` file, unpack, and then set the environment variable as the doc states.

But you are already trying to install the NuGet pacakge, so let's stick to that.

Typically people install NuGet packages directly in Visual Studio (Right click on the project you want to add the agent to -\> click on Manage NuGet Pacakges -\> A new windows pops up -\> Click on the browse tab -\> enter the Elastic.Apm.\* -\> select and click install).

Other way to do this is to use the `dotnet` command - once you install the .NET CLI, you can execute

```auto
dotnet add package Elastic.Apm.AspNetCore --version 1.6.1

```

Alternatively you can also pull `nuget.exe` from [here](https://www.nuget.org/downloads) and execute:

```auto
nuget.exe install Elastic.Apm.AspNetCore -Version 1.6.1 -PreRelease

```

[This](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools) is a good overview from Microsoft on all the ways people can use to install NuGet packages.

Now to the command you pasted (Sorry I did not look at those enough when I wrote my 1. response).

Do you run those commands in a plain PowerShell command outside Visual Studio? To be honest I never installed NuGet pacakges from PowerShell directly. Those commands should typically run in the Visual Studio (Tools -\> Package Manager -\> Package Manager console).

I tested and it works for me

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/5/e51223be9ca5886c3532c3196559e94b6d366aef.png)

This is also a PowerShell command line, but with a different profile. There is also a note about this [here](https://docs.microsoft.com/en-us/nuget/reference/ps-reference/ps-ref-install-package)

I managed to make it work with PowerShell, I had the same issue as you originally, but then [this](https://stackoverflow.com/a/57554679) StackOverflow entry helped me - setting it to the old `v2` API made it work. But I think none or only very few of our users do this - I'd suggest not doing it.

I'd suggest to just pulling the `dotnet` CLI or `nuget.exe` and install the package with those if you want command line, or use Visual Studio or any other IDE that supports NuGet.

Also one comment to this part:

> I've used:  
> Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 -ProviderName NuGet  
> Install-Package Elastic.Apm.AspNetCore  
> Install-Package Elastic.Apm.AspNetCore -Version 1.6.1  
> and the latter 2 tells me: ...

One you installed `Elastic.Apm.NetCoreAll` you are good to go, that package contains `Elastic.Apm.AspNetCore`, so if you use the `NetCoreAll` package, there is no need to reference other agent packages (more on this in our docs).

Also keep in mind that the code change I pasted above is needed to complete the agent setup, unless you go with the startup attachment beta feature.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![ckough](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ckough/32/61892_2.png) [@ckough](https://discuss.elastic.co/u/ckough)\
**Post date:** [September 12, 2020, 5:23am UTC](https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038/5 "2020-09-12T05:23:23Z")

</div>

Hi Greg

Your suggestions work perfectly. Thank you for all the help!

---

<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:** [October 3, 2020, 1:23am UTC](https://discuss.elastic.co/t/how-to-setup-opbeans-dotnet-for-elastic-apm/248038/6 "2020-10-03T01:23:28Z")

</div>

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