|
| 1 | +# Azure Node Agent Site Extension |
| 2 | + |
| 3 | +This project creates an Azure site extension that automatically installs the New Relic Node Agent. This extension is designed for JVM applications running on Azure Windows compute resources. The site extensions follow [semantic versioning conventions](https://semver.org/). You can expect to find artifacts in [Nuget](https://www.nuget.org/). |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +This extension is designed for Node applications running on Azure Windows compute resources. |
| 8 | + |
| 9 | +**Note:** Make sure that the target application is stopped prior to installing the extension. |
| 10 | + |
| 11 | +From the Azure Home page, do the following: |
| 12 | +- Click the App Services tile |
| 13 | +- Click the name of the target application in the displayed list |
| 14 | +- On the options listed on the left, scroll down to "Extensions" located under the `Development Tools` category |
| 15 | +- Click on `+ Add` at the top of the page |
| 16 | +- From the extension drop down, select `New Relic Node Agent` |
| 17 | +- Click on the `Accept Legal Terms` link |
| 18 | +- Click `OK` on the bottom left of the page |
| 19 | +- Again, click `OK` on the bottom left of the page. This will begin installation of the extension |
| 20 | + |
| 21 | +Once installed, the extension creates the following artifacts: |
| 22 | +- Folder: `C:\home\node_modules\newrelic` - Contains the Node agent artifacts |
| 23 | +- XDT: `applicationHost.xdt` that will add the necessary environment variable on application startup |
| 24 | + |
| 25 | +If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.WebSites.Extension.NodeAgent\install.log`. |
| 26 | + |
| 27 | +## Getting Started |
| 28 | + |
| 29 | +Once the site extension is installed, you'll need to manually enter two configuration items before restarting your application: |
| 30 | +- On the options listed on the left, scroll down to "Configuration" located under the `Settings` category |
| 31 | +- On the configuration page, add the following two app settings: |
| 32 | + - `NEW_RELIC_LICENSE_KEY` - Your New Relic license key value |
| 33 | + - `NEW_RELIC_APP_NAME` - The name you wish your application to show up as in the New Relic Platform |
| 34 | + |
| 35 | +You can also add any additional [app settings](https://docs.newrelic.com/docs/apm/agents/node-agent/configuration/node-agent-configuration-config-file/#Environment_Variables) to configure the agent as needed. |
| 36 | + |
| 37 | +## Building |
| 38 | + |
| 39 | +### Installing Dependencies (for MacOS and Linux) |
| 40 | + |
| 41 | +- Download and install the latest version of [Mono](https://www.mono-project.com/download/stable/) |
| 42 | +- Download `nuget.exe`: `sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe` |
| 43 | +- Create an alias in your .bashrc or .zshrc for mono: `alias nuget="mono /usr/local/bin/nuget.exe"` |
| 44 | +- Download and install [.Net 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0). Using the installer will create a `dotnet` command that will be available when you restart your shell. |
| 45 | +- Restart your shell and execute `nuget` to verify your mono installation and `dotnet` to verify your .Net installation. |
| 46 | + |
| 47 | +References: |
| 48 | +- https://www.wiliam.com.au/wiliam-blog/creating-a-nuget-package |
| 49 | +- https://learn.microsoft.com/en-au/nuget/install-nuget-client-tools#nugetexe-cli |
| 50 | + |
| 51 | +### Publishing the Package |
| 52 | + |
| 53 | +#### Publishing the Package with the Script (recommended) |
| 54 | +- Your nuget package version is hardcoded in `version.txt`, update the file to change the version number. |
| 55 | +- Run `./publish.sh <NUGET_API_KEY> <NUGET_SOURCE>`: this will create the NuGet package and upload to the target repository |
| 56 | +- The parameters for `publish.sh` are the following: |
| 57 | + - `NUGET_API_KEY` - API key for uploading artifacts to the target NuGet repository |
| 58 | + - `NUGET_SOURCE` - Target NuGet repository (https://api.nuget.org/v3/index.json is the main, public URL) |
| 59 | + |
| 60 | +#### Manually publishing the Package |
| 61 | + |
| 62 | +- Change into the folder where the `.nuget` file exists |
| 63 | +- Replace `{VERSION}` in `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` with a version number you want to push. (DO NOT COMMIT THIS CHANGE) |
| 64 | +- Execute: `nuget pack NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` |
| 65 | +- This will create a package with the name: `NewRelic.Azure.WebSites.Extension.NodeAgent.VERSION.nupkg` |
| 66 | +- Execute: `dotnet nuget push NewRelic.Node.Azure.WebSites.Extension.nupkg --api-key NUGET_API_KEY --source NUGET_SOURCE` where `NUGET_API_KEY` is your NuGet API key and `NUGET_SOURCE` is the URL of the target NuGet site (https://api.nuget.org/v3/index.json is the main, public URL) |
| 67 | + |
| 68 | +For testing the extension, it is best to publish to a personel [MyGet repository](https://www.myget.org/). There you can publish and release packages without worrying about pushing your extension out to the publix. |
| 69 | + |
| 70 | +## Testing |
| 71 | + |
| 72 | +It is recommended you use a personnel repository created in [MyGet](https://www.myget.org/). |
| 73 | + |
| 74 | +Upload the nuget package then set up an app config variable in Azure: |
| 75 | +- `SCM_SITEEXTENSIONS_FEED_URL`: The URL to the private Nuget repository created when registering your myget.org account. For example: https://www.myget.org/F/username-nuget-test/api/v3/index.json |
| 76 | + |
| 77 | +In Azure, when you browse to `Development Tools` > `Extensions`, you will see a list of Nuget packages in your private repository. |
| 78 | + |
| 79 | + |
| 80 | +## Extension Source Files |
| 81 | + |
| 82 | +Below is a description of the files that make up the extension. This can be helpful for future maintenance on the extension or for the creation of another Site Extension. |
| 83 | + |
| 84 | +- `README.md` - This file |
| 85 | +- `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` - Contains the metadata about the target extension: Name, authors, copyright, etc. [Nuspec Format](https://learn.microsoft.com/en-us/nuget/reference/nuspec) |
| 86 | +- `publish.sh` - Simple script to package the script and upload to the Nuget repository |
| 87 | +- `Content/applicationHost.xdt` - XDT transformation to add the necessary agent startup environment variable to the app config when the app starts up |
| 88 | +- `Content/install.cmd` - Simple batch file that wraps a call to the Powershell `install.ps1` script |
| 89 | +- `Content/install.ps1` - Powershell script that downloads the agent bundle and installs it to the proper location on the host |
| 90 | +- `Content/uninstall.cmd` - Simple batch file that will remove the Node installtion artifacts when the extension is removed |
0 commit comments