Skip to content

Commit 468943a

Browse files
mrickardsvetlanabrennanjsumners-nr
authored
chore: Added CI for publishing agent as Azure site extension (#2488)
Signed-off-by: mrickard <[email protected]> Co-authored-by: Svetlana Brennan <[email protected]> Co-authored-by: James Sumners <[email protected]>
1 parent ebfa2e9 commit 468943a

File tree

9 files changed

+187
-21
lines changed

9 files changed

+187
-21
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Azure Site Extension
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec'
8+
9+
jobs:
10+
create_extension_bundle:
11+
runs-on: windows-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: ['lts/*']
16+
arch: [ x64 ]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup dotnet '6.0.x'
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: '6.0.x'
25+
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
architecture: ${{ matrix.arch }}
31+
32+
- name: Find agent version
33+
run: |
34+
$env:npm_agent_version = npm view newrelic version
35+
echo "AGENT_VERSION=$env:npm_agent_version" | Out-File -FilePath $env:GITHUB_ENV -Append
36+
37+
- name: Set package filename
38+
run: |
39+
echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent-${{env.AGENT_VERSION}}" | Out-File -FilePath $env:GITHUB_ENV -Append
40+
41+
- name: Verify environment vars # because we can't access GH env vars until the next step
42+
run: |
43+
echo "Agent version: ${{ env.AGENT_VERSION }}"
44+
echo "Package filename: ${{ env.PACKAGE_FILENAME }}"
45+
46+
- name: Install agent
47+
working-directory: cloud-tooling/azure-site-extension/Content
48+
run: |
49+
npm i --prefix . newrelic@${{ env.AGENT_VERSION }}
50+
echo "Agent installed"
51+
52+
- name: Configure package files
53+
working-directory: cloud-tooling/azure-site-extension
54+
run: |
55+
(Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec
56+
57+
- name: Create bundle
58+
working-directory: cloud-tooling/azure-site-extension
59+
run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec"
60+
61+
# This step is for us to check what's going to be published
62+
- name: Archive package for verification
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }}
66+
path: cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nupkg
67+
68+
- name: Publish site extension
69+
working-directory: cloud-tooling/azure-site-extension
70+
run: |
71+
dotnet nuget push "${{ env.PACKAGE_FILENAME }}.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ secrets.NUGET_SOURCE }}

THIRD_PARTY_NOTICES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ SOFTWARE.
10761076

10771077
### @aws-sdk/client-s3
10781078

1079-
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):
1079+
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):
10801080

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

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

1288-
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):
1288+
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):
12891289

12901290
```
12911291
Apache License
@@ -2656,7 +2656,7 @@ SOFTWARE.
26562656

26572657
### async
26582658

2659-
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):
2659+
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):
26602660

26612661
```
26622662
Copyright (c) 2010-2018 Caolan McMahon
@@ -2683,7 +2683,7 @@ THE SOFTWARE.
26832683

26842684
### aws-sdk
26852685

2686-
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):
2686+
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):
26872687

26882688
```
26892689
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 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/).
4+
5+
## Installation
6+
7+
Applying the site extension will install the New Relic Node agent.
8+
9+
From the Azure Home page, do the following:
10+
- Click the App Services tile
11+
- Click the name of the target application in the displayed list
12+
- On the options listed on the left, scroll down to "Extensions" located under the Development Tools category
13+
- Click on + Add at the top of the page
14+
- From the extension drop down, select New Relic Node Agent.
15+
- Check the box for accepting the legal terms
16+
- Click Add on the bottom of the page. This will begin installation of the extension.
17+
18+
Once installed, the extension creates the following artifacts:
19+
20+
- Folder: `C:\home\SiteExtensions\NewRelic.Azure.Websites.Extension.NodeAgent`
21+
- XDT: `applicationHost.xdt` that will add the necessary `NODE_OPTIONS` environment variable on application startup
22+
- The New Relic Node agent and dependencies will be installed into `C:\home\site\wwwroot\node_modules`
23+
24+
If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.Websites.Extension.NodeAgent\install.log`.
25+
26+
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`.
27+
28+
### Compatibility note:
29+
30+
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.
31+
32+
## Configuration
33+
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/).
34+
35+
Once the site extension is installed, you'll need to manually enter one configuration item before restarting your application.
36+
- On the options listed on the left, scroll down to "Environment variables" located under the "Settings" category and add the following:
37+
- `NEW_RELIC_LICENSE_KEY` - Your New Relic license key value
38+
39+
The Node agent automatically adds the `NODE_OPTIONS` environment variable with a value of `-r newrelic` which starts the agent.
40+
- Note: Any previously `NODE_OPTIONS` will be removed and reset with `-r newrelic`.
41+
42+
## Extension Source Files
43+
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.
44+
45+
- `README.md` - This file
46+
- `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` - Contains the metadata about the target extension: Name, authors, copyright, etc. Nuspec Format
47+
- `Content/applicationHost.xdt` - XDT transformation to add the necessary agent startup environment variable to the app config when the app starts up
48+
- `Content/install.cmd` - Simple batch file that wraps a call to the Powershell `install.ps1` script
49+
- `Content/install.ps1` - Powershell script that moves/installs the agent bundle to the proper location on the host
50+
- `Content/uninstall.cmd` - Simple batch file that will remove the Node installation artifacts when the extension is removed
51+
52+
Note: We recommend installing or removing this Azure site extension while your web application is stopped.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
3+
<system.webServer>
4+
<runtime xdt:Transform="InsertIfMissing" >
5+
<environmentVariables xdt:Transform="InsertIfMissing">
6+
<add name="NEW_RELIC_APP_NAME" xdt:Locator="Match(name)" xdt:Transform="RemoveAll"/>
7+
<add name="NEW_RELIC_APP_NAME" value="%WEBSITE_SITE_NAME%" xdt:Locator="Match(name)" xdt:Transform="Insert"/>
8+
<add name="NODE_OPTIONS" xdt:Locator="Match(name)" xdt:Transform="RemoveAll"/>
9+
<add name="NODE_OPTIONS" value="-r newrelic" xdt:Locator="Match(name)" xdt:Transform="Insert"/>
10+
</environmentVariables>
11+
</runtime>
12+
</system.webServer>
13+
</configuration>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
3+
<!-- This file exists to prevent applicationHost.xdt from being applied to scm host that runs
4+
other dotnet processes (dotnet build, csc etc. )-->
5+
</configuration>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<metadata>
4+
<id>NewRelic.Azure.WebSites.Extension.NodeAgent</id>
5+
<version>{VERSION}</version>
6+
<title>New Relic Node Agent {VERSION}</title>
7+
<authors>New Relic</authors>
8+
<license type="expression">Apache-2.0</license>
9+
<projectUrl>https://github.com/newrelic/node-newrelic</projectUrl>
10+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
11+
<description>This extension adds the New Relic Node Agent to your Azure WebSite.</description>
12+
<iconUrl>https://newrelic.com/static-assets/images/icons/avatar-newrelic.png</iconUrl>
13+
<icon>images\icon.png</icon>
14+
<copyright>New Relic, Inc., 2024</copyright>
15+
<tags>AzureSiteExtension</tags>
16+
<packageTypes>
17+
<packageType name="AzureSiteExtension" />
18+
</packageTypes>
19+
</metadata>
20+
<files>
21+
<file src="Content\**\*.*" target="content" />
22+
<file src="icon.png" target="images\" />
23+
</files>
24+
</package>
5.43 KB
Loading

third_party_manifest.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"lastUpdated": "Mon Aug 19 2024 14:49:27 GMT-0400 (Eastern Daylight Time)",
2+
"lastUpdated": "Fri Aug 30 2024 14:16:44 GMT-0500 (Central Daylight Time)",
33
"projectName": "New Relic Node Agent",
44
"projectUrl": "https://github.com/newrelic/node-newrelic",
55
"includeOptDeps": true,
@@ -226,28 +226,28 @@
226226
}
227227
},
228228
"devDependencies": {
229-
"@aws-sdk/client-s3@3.632.0": {
229+
"@aws-sdk/client-s3@3.637.0": {
230230
"name": "@aws-sdk/client-s3",
231-
"version": "3.632.0",
231+
"version": "3.637.0",
232232
"range": "^3.556.0",
233233
"licenses": "Apache-2.0",
234234
"repoUrl": "https://github.com/aws/aws-sdk-js-v3",
235-
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.632.0",
235+
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.637.0",
236236
"licenseFile": "node_modules/@aws-sdk/client-s3/LICENSE",
237-
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.632.0/LICENSE",
237+
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.637.0/LICENSE",
238238
"licenseTextSource": "file",
239239
"publisher": "AWS SDK for JavaScript Team",
240240
"url": "https://aws.amazon.com/javascript/"
241241
},
242-
"@aws-sdk/s3-request-presigner@3.632.0": {
242+
"@aws-sdk/s3-request-presigner@3.637.0": {
243243
"name": "@aws-sdk/s3-request-presigner",
244-
"version": "3.632.0",
244+
"version": "3.637.0",
245245
"range": "^3.556.0",
246246
"licenses": "Apache-2.0",
247247
"repoUrl": "https://github.com/aws/aws-sdk-js-v3",
248-
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.632.0",
248+
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.637.0",
249249
"licenseFile": "node_modules/@aws-sdk/s3-request-presigner/LICENSE",
250-
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.632.0/LICENSE",
250+
"licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.637.0/LICENSE",
251251
"licenseTextSource": "file",
252252
"publisher": "AWS SDK for JavaScript Team",
253253
"url": "https://aws.amazon.com/javascript/"
@@ -364,27 +364,27 @@
364364
"licenseTextSource": "file",
365365
"publisher": "Evgeny Poberezkin"
366366
},
367-
367+
368368
"name": "async",
369-
"version": "3.2.5",
369+
"version": "3.2.6",
370370
"range": "^3.2.4",
371371
"licenses": "MIT",
372372
"repoUrl": "https://github.com/caolan/async",
373-
"versionedRepoUrl": "https://github.com/caolan/async/tree/v3.2.5",
373+
"versionedRepoUrl": "https://github.com/caolan/async/tree/v3.2.6",
374374
"licenseFile": "node_modules/async/LICENSE",
375-
"licenseUrl": "https://github.com/caolan/async/blob/v3.2.5/LICENSE",
375+
"licenseUrl": "https://github.com/caolan/async/blob/v3.2.6/LICENSE",
376376
"licenseTextSource": "file",
377377
"publisher": "Caolan McMahon"
378378
},
379-
"aws-sdk@2.1677.0": {
379+
"aws-sdk@2.1687.0": {
380380
"name": "aws-sdk",
381-
"version": "2.1677.0",
381+
"version": "2.1687.0",
382382
"range": "^2.1604.0",
383383
"licenses": "Apache-2.0",
384384
"repoUrl": "https://github.com/aws/aws-sdk-js",
385-
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1677.0",
385+
"versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1687.0",
386386
"licenseFile": "node_modules/aws-sdk/LICENSE.txt",
387-
"licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1677.0/LICENSE.txt",
387+
"licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1687.0/LICENSE.txt",
388388
"licenseTextSource": "file",
389389
"publisher": "Amazon Web Services",
390390
"url": "https://aws.amazon.com/"

0 commit comments

Comments
 (0)