Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Added CI for publishing agent as Azure site extension #2488

Merged
merged 41 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f2555b3
feat: Testing tooling available to windows runners
mrickard Aug 8, 2024
74354f2
chore: Added and debugged dotnet setup
mrickard Aug 8, 2024
5cf4ac2
fix: Fixed package creation and nuspec config
mrickard Aug 15, 2024
6fc46b3
fix: Set prefix flag on npm install, replaced cds with working-direct…
mrickard Aug 15, 2024
1d06677
chore: Added env vars for publish step, and added node options
mrickard Aug 16, 2024
3c5d197
chore: Edited README.md
mrickard Aug 16, 2024
71a8f62
chore: Updated name of publish step in workflow
mrickard Aug 16, 2024
81cfe2e
chore: Restored Node 18 publishing
mrickard Aug 16, 2024
36b1d9b
remove files that exist in another pr and add application host files
svetlanabrennan Aug 19, 2024
92243ff
Add site extension file and action to update site extension version
svetlanabrennan Aug 19, 2024
40306fd
Add site extension file
svetlanabrennan Aug 19, 2024
d6f10fd
Add readme and remove unnecessary site extension file
svetlanabrennan Aug 22, 2024
2ba039a
uncomment publish step
svetlanabrennan Aug 22, 2024
4e1d6c2
Update .github/workflows/azure-site-extension.yml
svetlanabrennan Aug 22, 2024
0ddef71
Update .github/workflows/azure-site-extension.yml
svetlanabrennan Aug 22, 2024
ff619cf
remove node versions
svetlanabrennan Aug 23, 2024
4187e23
chore: Included .NET setup in site extension bundle job
mrickard Aug 26, 2024
81db08e
feat: Testing tooling available to windows runners
mrickard Aug 8, 2024
e2d2463
chore: Added and debugged dotnet setup
mrickard Aug 8, 2024
96dc84e
fix: Fixed package creation and nuspec config
mrickard Aug 15, 2024
708e930
fix: Set prefix flag on npm install, replaced cds with working-direct…
mrickard Aug 15, 2024
6ed7c93
chore: Added env vars for publish step, and added node options
mrickard Aug 16, 2024
214b478
chore: Edited README.md
mrickard Aug 16, 2024
6fb7306
chore: Updated name of publish step in workflow
mrickard Aug 16, 2024
9350bed
chore: Restored Node 18 publishing
mrickard Aug 16, 2024
ab7658e
remove files that exist in another pr and add application host files
svetlanabrennan Aug 19, 2024
7e5984f
Add site extension file and action to update site extension version
svetlanabrennan Aug 19, 2024
50de73b
Add site extension file
svetlanabrennan Aug 19, 2024
9c1647b
Add readme and remove unnecessary site extension file
svetlanabrennan Aug 22, 2024
be76fdd
uncomment publish step
svetlanabrennan Aug 22, 2024
1f184f9
Update .github/workflows/azure-site-extension.yml
svetlanabrennan Aug 22, 2024
e6b6e06
Update .github/workflows/azure-site-extension.yml
svetlanabrennan Aug 22, 2024
db67d36
remove node versions
svetlanabrennan Aug 23, 2024
69bc4d3
chore: Included .NET setup in site extension bundle job
mrickard Aug 26, 2024
23d3552
update workflow to include arch and remove setting app name in readme
svetlanabrennan Aug 30, 2024
9998250
Merge branch 'NR-300979/azure-windows-workflow' of github.com:mrickar…
svetlanabrennan Aug 30, 2024
7934b6c
Remove x86 from workflow
svetlanabrennan Sep 3, 2024
2559216
chore: Edited README.md
mrickard Sep 3, 2024
77a53c0
chore: Restored x86 build. Added compatibility note to readme. Added …
mrickard Sep 4, 2024
759ea11
chore: Removed x86 build, removed architecture from nuspec, updated r…
mrickard Sep 5, 2024
93aae61
chore: Removed architecture notation from site extension filename
mrickard Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/*']
mrickard marked this conversation as resolved.
Show resolved Hide resolved
arch: [ x64 ]
mrickard marked this conversation as resolved.
Show resolved Hide resolved

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
mrickard marked this conversation as resolved.
Show resolved Hide resolved
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