forked from newrelic/node-newrelic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Added CI for publishing agent as Azure site extension (newreli…
…c#2488) 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
1 parent
ebfa2e9
commit 351aaff
Showing
9 changed files
with
187 additions
and
21 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
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 }} |
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 @@ | ||
NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg |
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,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
13
cloud-tooling/azure-site-extension/Content/applicationHost.xdt
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,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> |
5 changes: 5 additions & 0 deletions
5
cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt
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,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> |
24 changes: 24 additions & 0 deletions
24
cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec
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,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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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