Skip to content

Commit

Permalink
chore: Added CI for publishing agent as Azure site extension (#2488)
Browse files Browse the repository at this point in the history
Signed-off-by: mrickard <maurice@mauricerickard.com>
Co-authored-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Co-authored-by: James Sumners <jsumners@newrelic.com>
  • Loading branch information
3 people authored Sep 6, 2024
1 parent ebfa2e9 commit 468943a
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 21 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/azure-site-extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Azure Site Extension

on:
workflow_dispatch:

env:
SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec'

jobs:
create_extension_bundle:
runs-on: windows-latest

strategy:
matrix:
node-version: ['lts/*']
arch: [ x64 ]

steps:
- uses: actions/checkout@v4

- name: Setup dotnet '6.0.x'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
architecture: ${{ matrix.arch }}

- name: Find agent version
run: |
$env:npm_agent_version = npm view newrelic version
echo "AGENT_VERSION=$env:npm_agent_version" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Set package filename
run: |
echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent-${{env.AGENT_VERSION}}" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Verify environment vars # because we can't access GH env vars until the next step
run: |
echo "Agent version: ${{ env.AGENT_VERSION }}"
echo "Package filename: ${{ env.PACKAGE_FILENAME }}"
- name: Install agent
working-directory: cloud-tooling/azure-site-extension/Content
run: |
npm i --prefix . newrelic@${{ env.AGENT_VERSION }}
echo "Agent installed"
- name: Configure package files
working-directory: cloud-tooling/azure-site-extension
run: |
(Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec
- name: Create bundle
working-directory: cloud-tooling/azure-site-extension
run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec"

# This step is for us to check what's going to be published
- name: Archive package for verification
uses: actions/upload-artifact@v4
with:
name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }}
path: cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nupkg

- name: Publish site extension
working-directory: cloud-tooling/azure-site-extension
run: |
dotnet nuget push "${{ env.PACKAGE_FILENAME }}.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ secrets.NUGET_SOURCE }}
8 changes: 4 additions & 4 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ SOFTWARE.

### @aws-sdk/client-s3

This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.632.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.632.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.632.0/LICENSE):
This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.637.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.637.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.637.0/LICENSE):

```
Apache License
Expand Down Expand Up @@ -1285,7 +1285,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co

### @aws-sdk/s3-request-presigner

This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.632.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.632.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.632.0/LICENSE):
This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.637.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.637.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.637.0/LICENSE):

```
Apache License
Expand Down Expand Up @@ -2656,7 +2656,7 @@ SOFTWARE.

### async

This product includes source derived from [async](https://github.com/caolan/async) ([v3.2.5](https://github.com/caolan/async/tree/v3.2.5)), distributed under the [MIT License](https://github.com/caolan/async/blob/v3.2.5/LICENSE):
This product includes source derived from [async](https://github.com/caolan/async) ([v3.2.6](https://github.com/caolan/async/tree/v3.2.6)), distributed under the [MIT License](https://github.com/caolan/async/blob/v3.2.6/LICENSE):

```
Copyright (c) 2010-2018 Caolan McMahon
Expand All @@ -2683,7 +2683,7 @@ THE SOFTWARE.

### aws-sdk

This product includes source derived from [aws-sdk](https://github.com/aws/aws-sdk-js) ([v2.1677.0](https://github.com/aws/aws-sdk-js/tree/v2.1677.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js/blob/v2.1677.0/LICENSE.txt):
This product includes source derived from [aws-sdk](https://github.com/aws/aws-sdk-js) ([v2.1687.0](https://github.com/aws/aws-sdk-js/tree/v2.1687.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js/blob/v2.1687.0/LICENSE.txt):

```
Expand Down
1 change: 1 addition & 0 deletions cloud-tooling/azure-site-extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg
52 changes: 52 additions & 0 deletions cloud-tooling/azure-site-extension/Content/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Azure Node Agent Site Extension

This project creates an Azure site extension that automatically installs the New Relic Node Agent. This extension is designed for Node 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/).

## Installation

Applying the site extension will install the New Relic Node agent.

From the Azure Home page, do the following:
- Click the App Services tile
- Click the name of the target application in the displayed list
- On the options listed on the left, scroll down to "Extensions" located under the Development Tools category
- Click on + Add at the top of the page
- From the extension drop down, select New Relic Node Agent.
- Check the box for accepting the legal terms
- Click Add on the bottom of the page. This will begin installation of the extension.

Once installed, the extension creates the following artifacts:

- Folder: `C:\home\SiteExtensions\NewRelic.Azure.Websites.Extension.NodeAgent`
- XDT: `applicationHost.xdt` that will add the necessary `NODE_OPTIONS` environment variable on application startup
- The New Relic Node agent and dependencies will be installed into `C:\home\site\wwwroot\node_modules`

If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.Websites.Extension.NodeAgent\install.log`.

If the New Relic agent has been installed successfully and logging has been enabled, the agent will append its logs to a file at `C:\home\site\wwwroot\newrelic_agent.log`.

### Compatibility note:

For applications running on Win 32, full Code Level Metrics support (file path, line, column) is not available, and profiling will fall back to function name only.

## Configuration
The New Relic Node agent is configured with the `newrelic.js` file, or via environment variables. [See our documentation for more detailed configuration](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/).

Once the site extension is installed, you'll need to manually enter one configuration item before restarting your application.
- On the options listed on the left, scroll down to "Environment variables" located under the "Settings" category and add the following:
- `NEW_RELIC_LICENSE_KEY` - Your New Relic license key value

The Node agent automatically adds the `NODE_OPTIONS` environment variable with a value of `-r newrelic` which starts the agent.
- Note: Any previously `NODE_OPTIONS` will be removed and reset with `-r newrelic`.

## Extension Source Files
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.

- `README.md` - This file
- `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` - Contains the metadata about the target extension: Name, authors, copyright, etc. Nuspec Format
- `Content/applicationHost.xdt` - XDT transformation to add the necessary agent startup environment variable to the app config when the app starts up
- `Content/install.cmd` - Simple batch file that wraps a call to the Powershell `install.ps1` script
- `Content/install.ps1` - Powershell script that moves/installs the agent bundle to the proper location on the host
- `Content/uninstall.cmd` - Simple batch file that will remove the Node installation artifacts when the extension is removed

Note: We recommend installing or removing this Azure site extension while your web application is stopped.
13 changes: 13 additions & 0 deletions cloud-tooling/azure-site-extension/Content/applicationHost.xdt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<runtime xdt:Transform="InsertIfMissing" >
<environmentVariables xdt:Transform="InsertIfMissing">
<add name="NEW_RELIC_APP_NAME" xdt:Locator="Match(name)" xdt:Transform="RemoveAll"/>
<add name="NEW_RELIC_APP_NAME" value="%WEBSITE_SITE_NAME%" xdt:Locator="Match(name)" xdt:Transform="Insert"/>
<add name="NODE_OPTIONS" xdt:Locator="Match(name)" xdt:Transform="RemoveAll"/>
<add name="NODE_OPTIONS" value="-r newrelic" xdt:Locator="Match(name)" xdt:Transform="Insert"/>
</environmentVariables>
</runtime>
</system.webServer>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- This file exists to prevent applicationHost.xdt from being applied to scm host that runs
other dotnet processes (dotnet build, csc etc. )-->
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<package>
<metadata>
<id>NewRelic.Azure.WebSites.Extension.NodeAgent</id>
<version>{VERSION}</version>
<title>New Relic Node Agent {VERSION}</title>
<authors>New Relic</authors>
<license type="expression">Apache-2.0</license>
<projectUrl>https://github.com/newrelic/node-newrelic</projectUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>This extension adds the New Relic Node Agent to your Azure WebSite.</description>
<iconUrl>https://newrelic.com/static-assets/images/icons/avatar-newrelic.png</iconUrl>
<icon>images\icon.png</icon>
<copyright>New Relic, Inc., 2024</copyright>
<tags>AzureSiteExtension</tags>
<packageTypes>
<packageType name="AzureSiteExtension" />
</packageTypes>
</metadata>
<files>
<file src="Content\**\*.*" target="content" />
<file src="icon.png" target="images\" />
</files>
</package>
Binary file added cloud-tooling/azure-site-extension/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions third_party_manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lastUpdated": "Mon Aug 19 2024 14:49:27 GMT-0400 (Eastern Daylight Time)",
"lastUpdated": "Fri Aug 30 2024 14:16:44 GMT-0500 (Central Daylight Time)",
"projectName": "New Relic Node Agent",
"projectUrl": "https://github.com/newrelic/node-newrelic",
"includeOptDeps": true,
Expand Down Expand Up @@ -226,28 +226,28 @@
}
},
"devDependencies": {
"@aws-sdk/client-s3@3.632.0": {
"@aws-sdk/client-s3@3.637.0": {
"name": "@aws-sdk/client-s3",
"version": "3.632.0",
"version": "3.637.0",
"range": "^3.556.0",
"licenses": "Apache-2.0",
"repoUrl": "https://github.com/aws/aws-sdk-js-v3",
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.632.0",
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.637.0",
"licenseFile": "node_modules/@aws-sdk/client-s3/LICENSE",
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.632.0/LICENSE",
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.637.0/LICENSE",
"licenseTextSource": "file",
"publisher": "AWS SDK for JavaScript Team",
"url": "https://aws.amazon.com/javascript/"
},
"@aws-sdk/s3-request-presigner@3.632.0": {
"@aws-sdk/s3-request-presigner@3.637.0": {
"name": "@aws-sdk/s3-request-presigner",
"version": "3.632.0",
"version": "3.637.0",
"range": "^3.556.0",
"licenses": "Apache-2.0",
"repoUrl": "https://github.com/aws/aws-sdk-js-v3",
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.632.0",
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.637.0",
"licenseFile": "node_modules/@aws-sdk/s3-request-presigner/LICENSE",
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.632.0/LICENSE",
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.637.0/LICENSE",
"licenseTextSource": "file",
"publisher": "AWS SDK for JavaScript Team",
"url": "https://aws.amazon.com/javascript/"
Expand Down Expand Up @@ -364,27 +364,27 @@
"licenseTextSource": "file",
"publisher": "Evgeny Poberezkin"
},
"async@3.2.5": {
"async@3.2.6": {
"name": "async",
"version": "3.2.5",
"version": "3.2.6",
"range": "^3.2.4",
"licenses": "MIT",
"repoUrl": "https://github.com/caolan/async",
"versionedRepoUrl": "https://github.com/caolan/async/tree/v3.2.5",
"versionedRepoUrl": "https://github.com/caolan/async/tree/v3.2.6",
"licenseFile": "node_modules/async/LICENSE",
"licenseUrl": "https://github.com/caolan/async/blob/v3.2.5/LICENSE",
"licenseUrl": "https://github.com/caolan/async/blob/v3.2.6/LICENSE",
"licenseTextSource": "file",
"publisher": "Caolan McMahon"
},
"aws-sdk@2.1677.0": {
"aws-sdk@2.1687.0": {
"name": "aws-sdk",
"version": "2.1677.0",
"version": "2.1687.0",
"range": "^2.1604.0",
"licenses": "Apache-2.0",
"repoUrl": "https://github.com/aws/aws-sdk-js",
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1677.0",
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1687.0",
"licenseFile": "node_modules/aws-sdk/LICENSE.txt",
"licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1677.0/LICENSE.txt",
"licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1687.0/LICENSE.txt",
"licenseTextSource": "file",
"publisher": "Amazon Web Services",
"url": "https://aws.amazon.com/"
Expand Down

0 comments on commit 468943a

Please sign in to comment.