Install APM Insight .NET Agent in Kubernetes


Installing the .NET and .NET Core agents in a Kubernetes environment is similar to installing the standard .NET agent in Windows, except that you must configure the DockerFile to perform the installation.

Install the .NET agent in a Kubernetes Windows container

Below is an example of configuring the .NET agent on a Kubernetes Windows container.

FROM mcr.microsoft.com/dotnet/framework/aspnet

EXPOSE 80
# Publish your application
COPY <Your-app-to-be-published> /inetpub/wwwroot

# Download the APM Insight .NET agent installer
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\
Invoke-WebRequest "https://www.manageengine.com/products/applications_manager/54974026/apminsight-
dotnetagent.msi" -UseBasicParsing -OutFile "apminsight-dotnetagent.msi"

# Install the APM Insight .NET agent
RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "apminsight-
dotnetagent.msi", /qn, editconfig=false, useappfilters=false, license.key=<APM_LICENSE_KEY>, apm.host=
<APM_HOST>, apm.port=<APM_PORT>

# Remove the APM Insight .NET agent installer
RUN Remove-Item "apminsight-dotnetagent.msi"

Install the .NET Core agent in a Kubernetes Windows container

Below is an example of configuring the .NET Core agent on a Kubernetes Windows container.

FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Publish your application
COPY <Your-app-to-be-published>

#Install .NET core framework

RUN powershell.exe [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\
Invoke-WebRequest "https://download.visualstudio.microsoft.com/download/pr/a0832b5a-6900-442b-af79-
6ffddddd6ba4/e2df0b25dd851ee0b38a86947dd0e42e/dotnet-runtime-5.0.17-win-x64.exe" -UseBasicParsing-
OutFile "dotnet-runtime-5.0.17-win-x64.exe"

RUN dotnet-runtime-5.0.17-win-x64.exe /quiet /install
RUN powershell.exe [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\
Invoke-WebRequest "https://download.visualstudio.microsoft.com/download/pr/3789ec90-2717-424f-8b9c-
3adbbcea6c16/2085cc5ff077b8789ff938015392e406/aspnetcore-runtime-5.0.17-win-x64.exe" -UseBasicParsing-
OutFile "aspnetcore-runtime-5.0.17-win-x64.exe"

# Extract APM Insight .NET core agent zip
RUN powershell.exe Expand-Archive -LiteralPath 'apminsight-
dotnetcoreagent.zip' -DestinationPath apminsight-dotnetcoreagent

# Install the APM Insight .NET core agent
RUN powershell.exe ".\apminsight-dotnetcoreagent\dotnet_core\InstallAgent.ps1" -Destination ".\appmanager" -
InstallType global -LicenseKey <APM_LICENSE_KEY>

# Remove the APM Insight .NET agent installer zip
RUN powershell.exe Remove-Item "apminsight-dotnetcoreagent.zip"

# Remove the APM Insight .NET agent installer
RUN powershell.exe Remove-Item "apminsight-dotnetcoreagent" -Recurse -Force

#RUN setx path "%path%;.\Program Files\dotnet\"
RUN setx path "%path%;C:\Program Files (x86)\dotnet\"


WORKDIR /app

#ENTRYPOINT ["powershell.exe",".\\Program Files\\dotnet\\dotnet.exe", ".\\ASPNETWebApp.dll"]
ENTRYPOINT ["powershell.exe"]
CMD ["dotnet", "\\ASPNET5WebApp.dll", "--urls", "http://*:5000"]

After Kubernetes start,

  • Access the Kubernetes container and configure the application filters from the agent installed "./appmanager" path.
  • Start or Restart the .NET Core application. Perform some transactions to start monitoring.