-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18894 from jaffinito/azure-appservices-updates
.NET Azure: Update Azure installation workflow to include containerized apps.
- Loading branch information
Showing
3 changed files
with
222 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
componentType: default | ||
optionType: deployment | ||
headingText: Install in a Linux Docker container | ||
descriptionText: "" | ||
--- | ||
|
||
How you configure a containerized Web App to work with our .NET agent will depend on your setup. We'll give some example Docker files below but these are only examples. The Docker files are meant to accomplish the same things that our standard install procedures do. | ||
|
||
Some notes about how to implement your Docker file: | ||
|
||
* The .NET agent must be installed on the containers you want to monitor. | ||
* The .NET agent must be installed and enabled at runtime. | ||
* For .NET agent versions 10.0.0 or higher, the name of the package is `newrelic-dotnet-agent`. For .NET agent versions 9.9.0 or lower, the name of the package is `newrelic-netcore20-agent`. We'll use `newrelic-dotnet-agent` in this doc. | ||
* The license key and application name are not set directly in these docker file examples. Instead, set these values in Azure as app settings. | ||
|
||
Here are example Docker files for Linux. Additional examples for multiple Linux distros can be found in our [.NET agent samples repository](https://github.com/newrelic/newrelic-dotnet-examples). | ||
|
||
### Example Linux dockerfile | ||
|
||
```dockerfile | ||
# Use the correct tagged version for your application's targeted runtime. See https://hub.docker.com/_/microsoft-dotnet-aspnet/ | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 | ||
|
||
# Publish your application. | ||
COPY INSERT_NAME_OF_APP_TO_BE_PUBLISHED /app | ||
|
||
# Install the agent | ||
RUN apt-get update && apt-get install -y wget ca-certificates gnupg \ | ||
&& echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list \ | ||
&& wget https://download.newrelic.com/548C16BF.gpg \ | ||
&& apt-key add 548C16BF.gpg \ | ||
&& apt-get update \ | ||
&& apt-get install -y newrelic-dotnet-agent \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Enable the agent | ||
ENV CORECLR_ENABLE_PROFILING=1 \ | ||
CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A} \ | ||
CORECLR_NEWRELIC_HOME=/usr/local/newrelic-dotnet-agent \ | ||
CORECLR_PROFILER_PATH=/usr/local/newrelic-dotnet-agent/libNewRelicProfiler.so | ||
|
||
WORKDIR /app | ||
|
||
ENTRYPOINT ["dotnet", "./YOUR_APP_NAME.dll"] | ||
``` | ||
|
||
### Example Linux multi-stage dockerfile | ||
|
||
```dockerfile | ||
# This example uses .NET 6.0. For other versions, see https://hub.docker.com/_/microsoft-dotnet-sdk/ | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base | ||
|
||
# Build your application | ||
WORKDIR /src | ||
RUN dotnet new mvc -o YOUR_APP_NAME | ||
RUN dotnet publish -c Release -o /app ./YOUR_APP_NAME | ||
|
||
# The runtime tag version should match the SDK tag version | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final | ||
|
||
# Install the agent | ||
RUN apt-get update && apt-get install -y wget ca-certificates gnupg \ | ||
&& echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list \ | ||
&& wget https://download.newrelic.com/548C16BF.gpg \ | ||
&& apt-key add 548C16BF.gpg \ | ||
&& apt-get update \ | ||
&& apt-get install -y newrelic-dotnet-agent | ||
|
||
# Enable the agent | ||
ENV CORECLR_ENABLE_PROFILING=1 \ | ||
CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A} \ | ||
CORECLR_NEWRELIC_HOME=/usr/local/newrelic-dotnet-agent \ | ||
CORECLR_PROFILER_PATH=/usr/local/newrelic-dotnet-agent/libNewRelicProfiler.so | ||
|
||
WORKDIR /app | ||
COPY --from=base /app . | ||
|
||
ENTRYPOINT ["dotnet", "./INSERT_YOUR_APP_NAME.dll"] | ||
``` |
103 changes: 103 additions & 0 deletions
103
src/install/dotnet/installation/azure-windows-container.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
componentType: default | ||
optionType: deployment | ||
headingText: Install in a Windows Docker container | ||
descriptionText: "" | ||
--- | ||
|
||
How you configure Docker to work with our .NET agent will depend on your setup. We'll give some example Docker files below but these are only examples. The Docker files are meant to accomplish the same things that our standard install procedures do. | ||
|
||
Some notes about how to implement your Docker file: | ||
|
||
* The .NET agent must be installed on the containers you want to monitor. | ||
* The .NET agent must be installed and enabled at runtime. | ||
* The license key and application name are not set directly in these docker file examples. Instead, set these values in Azure as app settings. | ||
|
||
<Callout variant="important"> | ||
Note that Windows Nano Server images aren't supported. | ||
</Callout> | ||
|
||
### Example Windows dockerfile for .NET framework application using IIS [#example-windows-dockerfile-framework] | ||
|
||
```dockerfile | ||
FROM mcr.microsoft.com/dotnet/framework/aspnet | ||
|
||
# Publish your application. | ||
COPY YOUR_APP_TO_BE_PUBLISHED /inetpub/wwwroot | ||
|
||
# Download the New Relic .NET agent installer | ||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\ | ||
Invoke-WebRequest "https://download.newrelic.com/dot_net_agent/latest_release/NewRelicDotNetAgent_x64.msi"\ | ||
-UseBasicParsing -OutFile "NewRelicDotNetAgent_x64.msi" | ||
|
||
# Install the New Relic .NET agent | ||
RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "NewRelicDotNetAgent_x64.msi", /qn | ||
|
||
# Remove the New Relic .NET agent installer | ||
RUN Remove-Item "NewRelicDotNetAgent_x64.msi" | ||
``` | ||
|
||
### Example Windows dockerfile for .NET framework application not using IIS [#example-windows-dockerfile-framework-notiis] | ||
|
||
<Callout variant="important"> | ||
Enable the agent for your application using: | ||
* [application config](/install/dotnet/?deployment=windowsInstallNonIis&docker=noDocker#app-config) | ||
* [app name in newrelic.config](/install/dotnet/?deployment=windowsInstallNonIis&docker=noDocker#newrelic-config) | ||
* [a local newrelic.config](/install/dotnet/?deployment=windowsInstallNonIis&docker=noDocker#newrelic-config-local) | ||
|
||
For both newrelic.config options, the modified newrelic.config will need to be copied into the container in a separate COPY step. | ||
</Callout> | ||
|
||
```dockerfile | ||
FROM mcr.microsoft.com/dotnet/framework/aspnet | ||
|
||
# Publish your application. | ||
COPY YOUR_APP_TO_BE_PUBLISHED /app | ||
|
||
# Download the New Relic .NET agent installer | ||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\ | ||
Invoke-WebRequest "https://download.newrelic.com/dot_net_agent/latest_release/NewRelicDotNetAgent_x64.msi"\ | ||
-UseBasicParsing -OutFile "NewRelicDotNetAgent_x64.msi" | ||
|
||
# Install the New Relic .NET agent | ||
RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "NewRelicDotNetAgent_x64.msi", /qn, INSTALLLEVEL=50 | ||
|
||
# Remove the New Relic .NET agent installer | ||
RUN Remove-Item "NewRelicDotNetAgent_x64.msi" | ||
|
||
# [OPTIONAL] Copy the newrelic.config file into the container | ||
# COPY path/to/newrelic.config /app | ||
|
||
ENTRYPOINT ["INSERT_YOUR_APP_NAME.exe"] | ||
``` | ||
|
||
### Example Windows dockerfile for .NET Core application [#example-windows-dockerfile-net-core] | ||
|
||
```dockerfile | ||
FROM mcr.microsoft.com/windows/servercore:ltsc2019 | ||
|
||
# Publish your application. | ||
COPY INSERT_NAME_OF_APP_TO_BE_PUBLISHED /app | ||
|
||
# Download the New Relic .NET agent installer | ||
RUN powershell.exe [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\ | ||
Invoke-WebRequest "https://download.newrelic.com/dot_net_agent/latest_release/NewRelicDotNetAgent_x64.msi"\ | ||
-UseBasicParsing -OutFile "NewRelicDotNetAgent_x64.msi" | ||
|
||
# Install the New Relic .NET agent | ||
RUN powershell.exe Start-Process -Wait -FilePath msiexec -ArgumentList /i, "NewRelicDotNetAgent_x64.msi", /qn | ||
|
||
# Remove the New Relic .NET agent installer | ||
RUN powershell.exe Remove-Item "NewRelicDotNetAgent_x64.msi" | ||
|
||
# Enable the agent | ||
ENV CORECLR_ENABLE_PROFILING=1 | ||
|
||
# windows/servercore images may not include the .NET Core SDK or runtime | ||
RUN dotnet sdk/runtime installer | ||
|
||
WORKDIR /app | ||
|
||
ENTRYPOINT ["dotnet", ".\\INSERT_YOUR_APP_NAME.dll"] | ||
``` | ||
|