---
title: ".NET APM with Kubernetes"
slug: "net-core-apm-with-kubernetes"
description: "Install .Net Core APM Profiler for your Kubernetes application. Follow the guide to set up and verify performance results in Retrace dashboard."
updated: 2023-08-01T06:16:03Z
published: 2023-08-01T06:16:03Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# .NET APM with Kubernetes

This document details how to install the **.Net Core APM Profiler** in your **.Net Core** application running on **Kubernetes**.

## Prerequisite

Follow the [Retrace Kubernetes Install](https://docs.stackify.com/docs/retrace-kubernetes-install) Guide.

## .Net Core Kubernetes Setup

#### Dockerfile Configuration

Adjust your **Dockerfile** to include the .Net Core Profiler:

```
RUN mkdir -m 0755 -p /stackify-dotnet-apm && \
    cd /stackify-dotnet-apm && \
    wget http://download.stackify.com/stackify-dotnet-apm/stackify-dotnet-apm-install-linux-latest.tar.gz && \
    tar -zxvf stackify-dotnet-apm-install-linux-latest.tar.gz && \
    cd stackify-dotnet-apm-install-linux && \
    ./install.sh --docker && \
    cd .. && \
    rm -rf stackify-dotnet-apm-install-linux && \
    rm stackify-dotnet-apm-install-linux-latest.tar.gz

ENV CORECLR_PROFILER={cf0d821e-299b-5307-a3d8-b283c03916da}
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER_PATH="/stackify-dotnet-apm/StackifyProfiler.so"
```

#### Name Your Application

Create a file named Stackify.json and copy it to your container in the same folder as your application.

```
{
    "AppName": "MyApp",
    "Environment": "Production"
}
```

#### Sending All Exceptions to Retrace

By default the profiler only captures "unhandled" exceptions to avoid the overhead of a first-chance exception handler. However, if you want to capture and upload all first-chance exceptions you can enable this on a per application basis. To enable this, add the setting `CaptureAllExceptions` to the `Stackify.json` file as shown in the following example.

```
{
    "AppName": "MyApp",
    "Environment": "Production",
    "CaptureAllExceptions": true
}
```

#### Pod Configuration

Application containers are required to have the **stackify** volume mount configured in [Retrace Kubernetes Install](https://docs.stackify.com/docs/retrace-kubernetes-install).

Example Application Pod YAML:

```
apiVersion: v1
kind: ReplicationController
metadata:
  name: pod-name
spec:
  replicas: 1
  selector:
    app: app-name
  template:
    metadata:
      name: template-name
      labels:
        app: app-name
    spec:
      containers:
      - name: container-name
        image: application-image
        volumeMounts:
          - mountPath: /usr/local/stackify
            name: stackify
      volumes:
        - name: stackify
          hostPath: 
            path: /var/stackify
            type: DirectoryOrCreate
```

## Verify

Make application requests, you can then verify results in the Retrace dashboard.
