|
| 1 | +--- |
| 2 | +title: Set up App and API Protection for .NET on Linux |
| 3 | +code_lang: linux |
| 4 | +type: multi-code-lang |
| 5 | +code_lang_weight: 30 |
| 6 | +further_reading: |
| 7 | +- link: "/security/application_security/how-it-works/" |
| 8 | + tag: "Documentation" |
| 9 | + text: "How App and API Protection Works" |
| 10 | +- link: "/security/default_rules/?category=cat-application-security" |
| 11 | + tag: "Documentation" |
| 12 | + text: "OOTB App and API Protection Rules" |
| 13 | +- link: "/security/application_security/troubleshooting" |
| 14 | + tag: "Documentation" |
| 15 | + text: "Troubleshooting App and API Protection" |
| 16 | +--- |
| 17 | +{{% app_and_api_protection_dotnet_setup_options platform="linux" %}} |
| 18 | + |
| 19 | +{{% app_and_api_protection_dotnet_overview %}} |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +- Linux operating system |
| 24 | +- .NET application |
| 25 | +- Root or sudo privileges |
| 26 | +- Systemd (for service management) |
| 27 | +- Your Datadog API key |
| 28 | +- Datadog .NET tracing library (see version requirements [here][1]) |
| 29 | + |
| 30 | +## 1. Installing the Datadog Agent |
| 31 | + |
| 32 | +Install the Datadog Agent by following the [setup instructions for Linux hosts][2]. |
| 33 | + |
| 34 | +## 2. Enabling App and API Protection monitoring |
| 35 | + |
| 36 | +{{% app_and_api_protection_navigation_menu %}} |
| 37 | +{{% appsec-remote-config-activation %}} |
| 38 | + |
| 39 | +### Manually enabling App and API Protection monitoring |
| 40 | + |
| 41 | +{{< tabs >}} |
| 42 | +{{% tab "AMD 64 Platforms" %}} |
| 43 | + |
| 44 | +Download the latest [.NET Tracer package][3] that supports your operating system and architecture. |
| 45 | + |
| 46 | +**Note on version**: replace <TRACER_VERSION> with the latest three component version of the library (ej: 3.21.0) |
| 47 | + |
| 48 | +```bash |
| 49 | +wget -O datadog-dotnet-apm-<TRACER_VERSION>.tar.gz 'https://github.com/DataDog/dd-trace-dotnet/releases/download/v<TRACER_VERSION>' |
| 50 | +``` |
| 51 | + |
| 52 | +Run the following command to install the package and create the .NET tracer log directory `/var/log/datadog/dotnet` with the appropriate permissions: |
| 53 | + |
| 54 | +```bash |
| 55 | +sudo tar -C /opt/datadog -xzf datadog-dotnet-apm-<TRACER_VERSION>.tar.gz && /opt/datadog/createLogPath.sh |
| 56 | +``` |
| 57 | +{{% /tab %}} |
| 58 | +{{% tab "ARM 64 Platforms" %}} |
| 59 | + |
| 60 | +Download the latest [.NET Tracer package][1] that supports your operating system and architecture. |
| 61 | + |
| 62 | +**Note on version**: replace <TRACER_VERSION> with the latest three component version of the library (ej: 3.21.0) |
| 63 | + |
| 64 | +```bash |
| 65 | +wget -O datadog-dotnet-apm-<TRACER_VERSION>.arm64.tar.gz 'https://github.com/DataDog/dd-trace-dotnet/releases/download/v<TRACER_VERSION>' |
| 66 | +``` |
| 67 | + |
| 68 | +Run the following command to install the package and create the .NET tracer log directory `/var/log/datadog/dotnet` with the appropriate permissions: |
| 69 | + |
| 70 | +```bash |
| 71 | +sudo tar -C /opt/datadog -xzf datadog-dotnet-apm-<TRACER_VERSION>.arm64.tar.gz && /opt/datadog/createLogPath.sh |
| 72 | +``` |
| 73 | + |
| 74 | +{{% /tab %}} |
| 75 | +{{< /tabs >}} |
| 76 | + |
| 77 | +{{% collapse-content title="APM Tracing Enabled" level="h4" %}} |
| 78 | +Set the required environment variables and start your .NET application: |
| 79 | + |
| 80 | +```bash |
| 81 | +export CORECLR_ENABLE_PROFILING=1 |
| 82 | +export CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8} |
| 83 | +export CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so |
| 84 | +export DD_DOTNET_TRACER_HOME=/opt/datadog |
| 85 | +export DD_SERVICE=<MY_SERVICE> |
| 86 | +export DD_ENV=<MY_ENV> |
| 87 | +export DD_APPSEC_ENABLED=true |
| 88 | +``` |
| 89 | +{{% /collapse-content %}} |
| 90 | + |
| 91 | +{{% collapse-content title="APM Tracing Disabled" level="h4" %}} |
| 92 | +To disable APM tracing while keeping App and API Protection enabled, you must set the APM tracing variable to false. |
| 93 | +```bash |
| 94 | +export CORECLR_ENABLE_PROFILING=1 |
| 95 | +export CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8} |
| 96 | +export CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so |
| 97 | +export DD_DOTNET_TRACER_HOME=/opt/datadog |
| 98 | +export DD_SERVICE=<MY_SERVICE> |
| 99 | +export DD_ENV=<MY_ENV> |
| 100 | +export DD_APPSEC_ENABLED=true |
| 101 | +export DD_APM_TRACING_ENABLED=false |
| 102 | +``` |
| 103 | + |
| 104 | +{{% /collapse-content %}} |
| 105 | + |
| 106 | +## 3. Run your application |
| 107 | + |
| 108 | +Start your Java application with above settings. |
| 109 | + |
| 110 | +{{% app_and_api_protection_verify_setup %}} |
| 111 | + |
| 112 | +## Troubleshooting |
| 113 | + |
| 114 | +If you encounter issues while setting up App and API Protection for your Java application, see the [.NET App and API Protection troubleshooting guide][4]. |
| 115 | + |
| 116 | +## Further Reading |
| 117 | + |
| 118 | +{{< partial name="whats-next/whats-next.html" >}} |
| 119 | + |
| 120 | +[1]: /security/application_security/setup/dotnet/compatibility |
| 121 | +[2]: /agent/?tab=Linux |
| 122 | +[3]: https://github.com/DataDog/dd-trace-dotnet/releases |
| 123 | +[4]: /security/application_security/setup/dotnet/troubleshooting |
0 commit comments