From f2555b317b90173277dfc149229e59e1f90f1cc1 Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 8 Aug 2024 16:01:46 -0400 Subject: [PATCH 01/40] feat: Testing tooling available to windows runners Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/azure-site-extension.yml diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml new file mode 100644 index 0000000000..9a99f4224f --- /dev/null +++ b/.github/workflows/azure-site-extension.yml @@ -0,0 +1,20 @@ +name: Azure Site Extension + +on: + workflow_dispatch: + +env: + # Enable versioned runner quiet mode to make CI output easier to read: + OUTPUT_MODE: quiet + +jobs: + test-environment: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - name: Try to run NuGet + run: nuget + - name: Try to run dotnet + run: dotnet + From 74354f2124fa2247b603cb3c8e6ad91cc0d5114c Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 8 Aug 2024 16:42:16 -0400 Subject: [PATCH 02/40] chore: Added and debugged dotnet setup --- .github/workflows/azure-site-extension.yml | 86 +++++++++++++++-- .../Content/applicationHost.xdt | 11 +++ .../azure-site-extension/Content/install.cmd | 8 ++ .../azure-site-extension/Content/install.ps1 | 43 +++++++++ .../Content/uninstall.cmd | 7 ++ ....Azure.WebSites.Extension.NodeAgent.nuspec | 24 +++++ cloud-tooling/azure-site-extension/README.md | 90 ++++++++++++++++++ cloud-tooling/azure-site-extension/icon.png | Bin 0 -> 5559 bytes cloud-tooling/azure-site-extension/publish.sh | 12 +++ .../azure-site-extension/version.txt | 1 + 10 files changed, 276 insertions(+), 6 deletions(-) create mode 100644 cloud-tooling/azure-site-extension/Content/applicationHost.xdt create mode 100644 cloud-tooling/azure-site-extension/Content/install.cmd create mode 100644 cloud-tooling/azure-site-extension/Content/install.ps1 create mode 100644 cloud-tooling/azure-site-extension/Content/uninstall.cmd create mode 100644 cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec create mode 100644 cloud-tooling/azure-site-extension/README.md create mode 100644 cloud-tooling/azure-site-extension/icon.png create mode 100755 cloud-tooling/azure-site-extension/publish.sh create mode 100644 cloud-tooling/azure-site-extension/version.txt diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 9a99f4224f..4e25a59ae5 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -5,16 +5,90 @@ on: env: # Enable versioned runner quiet mode to make CI output easier to read: - OUTPUT_MODE: quiet + # OUTPUT_MODE: quiet + SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec' jobs: - test-environment: + setup_tools: runs-on: windows-latest steps: - uses: actions/checkout@v4 - - name: Try to run NuGet - run: nuget - - name: Try to run dotnet - run: dotnet + - name: Setup dotnet '6.0.x' + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.0.x' + - name: Display dotnet version + run: dotnet --version + - name: Display NuGet version + run: nuget ? + + create_extension_bundle: + runs-on: windows-latest + needs: + - setup_tools + + strategy: + matrix: + node-version: ['20.x'] # Node 22 isn't yet available on Azure + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - 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}}.${{ matrix.node-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 }}" +# echo ("PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}.${{ matrix.node-version }}") >> $env:GITHUB_ENV + - name: install_agent + run: | + cd "cloud-tooling/azure-site-extension/Content" + pwd + npm i newrelic@${{ env.AGENT_VERSION }} + +# - name: configure_package +# run: | +# cd .. +# (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', ${{ env.AGENT_VERSION }}).Replace('{NODE_VERSION}', ${{ matrix.node-version }}) | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec +# get-content ${{ env.SPEC_FILE_TEMPLATE }} | %{$_ -replace "{VERSION}","${{ env.AGENT_VERSION }}"} >> ${{NUSPEC_GENERATED}} + +# - name: pack +# run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" -OutputDirectory=./azure-site-extension/dist +# - name: Archive package for verification +# uses: actions/upload-artifact@v4 +# with: +# name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }} +# path: ./azure-site-extension/dist/ + +# - name: publish_package +# run: | +# NUGET_API_KEY=$1 +# NUGET_SOURCE=$2 +# dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} +# + + +# - name: GitHub Example +# id: step_one +# run: | +# $env:npm_agent_version = npm view newrelic version +# echo "agent version? $env:npm_agent_version" +# echo "AGENT_VERSION=$env:AGENT_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append +# - name: Use the value +# id: step_two +# run: | +# echo "action state: ${{ env.action_state }}" # This will output 'yellow' +# echo "action state no-append: ${{ env.action_state_no_append }}" +# echo "AGENT_VERSION from shell: $env:AGENT_VERSION" +# echo "AGENT_VERSION from GitHub Actions: ${{ env.AGENT_VERSION }}" diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt new file mode 100644 index 0000000000..727bea69a9 --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd new file mode 100644 index 0000000000..1618af677e --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/install.cmd @@ -0,0 +1,8 @@ +:: Copyright 2022 New Relic Corporation. All rights reserved. +:: SPDX-License-Identifier: Apache-2.0 + +@echo off + +powershell.exe -ExecutionPolicy RemoteSigned -File install.ps1 + +echo %ERRORLEVEL% diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1 new file mode 100644 index 0000000000..767fc6802e --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/install.ps1 @@ -0,0 +1,43 @@ +############################################################ +# Copyright 2022 New Relic Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +############################################################ + +# Install.ps1 +# +# This version uses npm install, which we're not going to want to do +# in the released version + +try { + WriteToInstallLog "Start executing install.ps1" + + # Selects the agent version + $agentVersion = "latest" + if ($env:NEWRELIC_AGENT_VERSION_OVERRIDE -ne $null) { + $agentVersion = $env:NEWRELIC_AGENT_VERSION_OVERRIDE.ToString() + WriteToInstallLog "Installing Node agent version $agentVersion" + } else { + WriteToInstallLog "Installing the latest Node agent" + } + + WriteToInstallLog "Executing npm install newrelic@latest" + npm install newrelic@latest + + WriteToInstallLog "End executing install.ps1." + WriteToInstallLog "-----------------------------" + exit $LASTEXITCODE +} +catch +{ + $errorMessage = $_.Exception.Message + $errorLine = $_.InvocationInfo.ScriptLineNumber + WriteToInstallLog "Error at line $errorLine : $errorMessage" + WriteToInstallLog "Explicitly adding node to path" + SET PATH=C:\Program Files\Nodejs;%PATH% + WriteToInstallLog "Executing npm install newrelic@latest" + npm install newrelic@latest + WriteToInstallLog "End executing install.ps1." + WriteToInstallLog "-----------------------------" + + exit $LASTEXITCODE +} diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd new file mode 100644 index 0000000000..2a88ef5f3b --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/uninstall.cmd @@ -0,0 +1,7 @@ +:: Copyright 2022 New Relic Corporation. All rights reserved. +:: SPDX-License-Identifier: Apache-2.0 + +SET NEW_RELIC_FOLDER="%HOME%\node_modules/newrelic" +IF EXIST %NEW_RELIC_FOLDER% ( + npm uninstall newrelic +) diff --git a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec new file mode 100644 index 0000000000..0a1359b3e5 --- /dev/null +++ b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec @@ -0,0 +1,24 @@ + + + + NewRelic.Azure.WebSites.Extension.NodeAgent + {VERSION}-{NODE_VERSION} + New Relic Node Agent {VERSION} (Node.js {NODE_VERSION}) + New Relic + Apache-2.0 + https://github.com/newrelic/node-newrelic + true + This extension adds the New Relic Node Agent to your Azure WebSite. + https://newrelic.com/static-assets/images/icons/avatar-newrelic.png + images\icon.png + New Relic, Inc., 2024 + AzureSiteExtension + + + + + + + + + diff --git a/cloud-tooling/azure-site-extension/README.md b/cloud-tooling/azure-site-extension/README.md new file mode 100644 index 0000000000..960e74e8fb --- /dev/null +++ b/cloud-tooling/azure-site-extension/README.md @@ -0,0 +1,90 @@ +# 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 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/). + +## Installation + +This extension is designed for Node applications running on Azure Windows compute resources. + +**Note:** Make sure that the target application is stopped prior to installing the extension. + +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` +- Click on the `Accept Legal Terms` link +- Click `OK` on the bottom left of the page +- Again, click `OK` on the bottom left of the page. This will begin installation of the extension + +Once installed, the extension creates the following artifacts: +- Folder: `C:\home\node_modules\newrelic` - Contains the Node agent artifacts +- XDT: `applicationHost.xdt` that will add the necessary environment variable on application startup + +If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.WebSites.Extension.NodeAgent\install.log`. + +## Getting Started + +Once the site extension is installed, you'll need to manually enter two configuration items before restarting your application: +- On the options listed on the left, scroll down to "Configuration" located under the `Settings` category +- On the configuration page, add the following two app settings: + - `NEW_RELIC_LICENSE_KEY` - Your New Relic license key value + - `NEW_RELIC_APP_NAME` - The name you wish your application to show up as in the New Relic Platform + +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. + +## Building + +### Installing Dependencies (for MacOS and Linux) + +- Download and install the latest version of [Mono](https://www.mono-project.com/download/stable/) +- Download `nuget.exe`: `sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe` +- Create an alias in your .bashrc or .zshrc for mono: `alias nuget="mono /usr/local/bin/nuget.exe"` +- 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. +- Restart your shell and execute `nuget` to verify your mono installation and `dotnet` to verify your .Net installation. + +References: +- https://www.wiliam.com.au/wiliam-blog/creating-a-nuget-package +- https://learn.microsoft.com/en-au/nuget/install-nuget-client-tools#nugetexe-cli + +### Publishing the Package + +#### Publishing the Package with the Script (recommended) +- Your nuget package version is hardcoded in `version.txt`, update the file to change the version number. +- Run `./publish.sh `: this will create the NuGet package and upload to the target repository +- The parameters for `publish.sh` are the following: + - `NUGET_API_KEY` - API key for uploading artifacts to the target NuGet repository + - `NUGET_SOURCE` - Target NuGet repository (https://api.nuget.org/v3/index.json is the main, public URL) + +#### Manually publishing the Package + +- Change into the folder where the `.nuget` file exists +- Replace `{VERSION}` in `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` with a version number you want to push. (DO NOT COMMIT THIS CHANGE) +- Execute: `nuget pack NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` +- This will create a package with the name: `NewRelic.Azure.WebSites.Extension.NodeAgent.VERSION.nupkg` +- 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) + +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. + +## Testing + +It is recommended you use a personnel repository created in [MyGet](https://www.myget.org/). + +Upload the nuget package then set up an app config variable in Azure: +- `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 + +In Azure, when you browse to `Development Tools` > `Extensions`, you will see a list of Nuget packages in your private repository. + + +## 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](https://learn.microsoft.com/en-us/nuget/reference/nuspec) +- `publish.sh` - Simple script to package the script and upload to the Nuget repository +- `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 downloads the agent bundle and installs it to the proper location on the host +- `Content/uninstall.cmd` - Simple batch file that will remove the Node installtion artifacts when the extension is removed diff --git a/cloud-tooling/azure-site-extension/icon.png b/cloud-tooling/azure-site-extension/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ec5bab479fd89bd3cc13deb0f01a1ffaf39ca3dd GIT binary patch literal 5559 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 FV1h4Kaw7l$ literal 0 HcmV?d00001 diff --git a/cloud-tooling/azure-site-extension/publish.sh b/cloud-tooling/azure-site-extension/publish.sh new file mode 100755 index 0000000000..4da6e28765 --- /dev/null +++ b/cloud-tooling/azure-site-extension/publish.sh @@ -0,0 +1,12 @@ +# This is just a simple shell script that will later be +# used as a template for a GHA job for +# azure-site-extension site extension uploads. + +# Dependencies: .Net 5 and up or .Net Core, Mono, and the Nuget CLI. +NUGET_API_KEY=$1 +NUGET_SOURCE=$2 +VERSION=$(cat version.txt) +NUSPEC_GENERATED="NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nuspec" +sed "s/{VERSION}/${VERSION}/g" NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec > "${NUSPEC_GENERATED}" +nuget pack "${NUSPEC_GENERATED}" +dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} diff --git a/cloud-tooling/azure-site-extension/version.txt b/cloud-tooling/azure-site-extension/version.txt new file mode 100644 index 0000000000..4044f90867 --- /dev/null +++ b/cloud-tooling/azure-site-extension/version.txt @@ -0,0 +1 @@ +12.0.0 From 5cf4ac275e1d5057819038328dfcd70360e63bf9 Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 15 Aug 2024 12:05:04 -0400 Subject: [PATCH 03/40] fix: Fixed package creation and nuspec config Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 43 +++++++------------ .../{Content => tools}/install.cmd | 0 .../{Content => tools}/install.ps1 | 0 .../{Content => tools}/uninstall.cmd | 0 4 files changed, 15 insertions(+), 28 deletions(-) rename cloud-tooling/azure-site-extension/{Content => tools}/install.cmd (100%) rename cloud-tooling/azure-site-extension/{Content => tools}/install.ps1 (100%) rename cloud-tooling/azure-site-extension/{Content => tools}/uninstall.cmd (100%) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 4e25a59ae5..d45f1633e3 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup dotnet '6.0.x' - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: '6.0.x' - name: Display dotnet version @@ -49,46 +49,33 @@ jobs: run: | echo "Agent version: ${{ env.AGENT_VERSION }}" echo "Package filename: ${{ env.PACKAGE_FILENAME }}" -# echo ("PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}.${{ matrix.node-version }}") >> $env:GITHUB_ENV - - name: install_agent + - name: Install agent run: | cd "cloud-tooling/azure-site-extension/Content" - pwd npm i newrelic@${{ env.AGENT_VERSION }} -# - name: configure_package -# run: | -# cd .. -# (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', ${{ env.AGENT_VERSION }}).Replace('{NODE_VERSION}', ${{ matrix.node-version }}) | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec + - name: Configure package files + run: | + pwd + (Get-Content cloud-tooling/azure-site-extension/${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nuspec # get-content ${{ env.SPEC_FILE_TEMPLATE }} | %{$_ -replace "{VERSION}","${{ env.AGENT_VERSION }}"} >> ${{NUSPEC_GENERATED}} -# - name: pack -# run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" -OutputDirectory=./azure-site-extension/dist + - name: Create bundle + run: | + pwd + cd cloud-tooling/azure-site-extension/ + nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" + echo "Going to list directory contents" + Get-ChildItem -Path .\*.* -Recurse -Force + # - name: Archive package for verification # uses: actions/upload-artifact@v4 # with: # name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }} -# path: ./azure-site-extension/dist/ +# path: cloud-tooling/azure-site-extension/.* # - name: publish_package # run: | # NUGET_API_KEY=$1 # NUGET_SOURCE=$2 # dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} -# - - -# - name: GitHub Example -# id: step_one -# run: | -# $env:npm_agent_version = npm view newrelic version -# echo "agent version? $env:npm_agent_version" -# echo "AGENT_VERSION=$env:AGENT_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append -# - name: Use the value -# id: step_two -# run: | -# echo "action state: ${{ env.action_state }}" # This will output 'yellow' -# echo "action state no-append: ${{ env.action_state_no_append }}" -# echo "AGENT_VERSION from shell: $env:AGENT_VERSION" -# echo "AGENT_VERSION from GitHub Actions: ${{ env.AGENT_VERSION }}" - diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/tools/install.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/Content/install.cmd rename to cloud-tooling/azure-site-extension/tools/install.cmd diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/tools/install.ps1 similarity index 100% rename from cloud-tooling/azure-site-extension/Content/install.ps1 rename to cloud-tooling/azure-site-extension/tools/install.ps1 diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/tools/uninstall.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/Content/uninstall.cmd rename to cloud-tooling/azure-site-extension/tools/uninstall.cmd From 6fc46b306f2ffa3b98b41723210db6605c2236b2 Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 15 Aug 2024 17:23:30 -0400 Subject: [PATCH 04/40] fix: Set prefix flag on npm install, replaced cds with working-directory directives Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 29 ++++++++++--------- .../{ => Content}/README.md | 0 .../{tools => Content}/install.cmd | 0 .../{tools => Content}/install.ps1 | 0 .../{tools => Content}/uninstall.cmd | 0 cloud-tooling/azure-site-extension/publish.sh | 12 -------- .../azure-site-extension/version.txt | 1 - 7 files changed, 15 insertions(+), 27 deletions(-) rename cloud-tooling/azure-site-extension/{ => Content}/README.md (100%) rename cloud-tooling/azure-site-extension/{tools => Content}/install.cmd (100%) rename cloud-tooling/azure-site-extension/{tools => Content}/install.ps1 (100%) rename cloud-tooling/azure-site-extension/{tools => Content}/uninstall.cmd (100%) delete mode 100755 cloud-tooling/azure-site-extension/publish.sh delete mode 100644 cloud-tooling/azure-site-extension/version.txt diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index d45f1633e3..a41b4edf5f 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -44,35 +44,36 @@ jobs: $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}}.${{ matrix.node-version }}" | Out-File -FilePath $env:GITHUB_ENV -Append + run: | + echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}-${{ matrix.node-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 - run: | - cd "cloud-tooling/azure-site-extension/Content" - npm i newrelic@${{ env.AGENT_VERSION }} + working-directory: cloud-tooling/azure-site-extension/Content + run: npm i --prefix Content newrelic@${{ env.AGENT_VERSION }} - name: Configure package files + working-directory: cloud-tooling/azure-site-extension run: | - pwd - (Get-Content cloud-tooling/azure-site-extension/${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nuspec -# get-content ${{ env.SPEC_FILE_TEMPLATE }} | %{$_ -replace "{VERSION}","${{ env.AGENT_VERSION }}"} >> ${{NUSPEC_GENERATED}} + (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec - name: Create bundle + working-directory: cloud-tooling/azure-site-extension run: | - pwd - cd cloud-tooling/azure-site-extension/ + echo "Going to list Content directory contents" + Get-ChildItem -Path Content/* -Recurse -Force + echo "===================" nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" echo "Going to list directory contents" Get-ChildItem -Path .\*.* -Recurse -Force -# - 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/.* + - 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_package # run: | diff --git a/cloud-tooling/azure-site-extension/README.md b/cloud-tooling/azure-site-extension/Content/README.md similarity index 100% rename from cloud-tooling/azure-site-extension/README.md rename to cloud-tooling/azure-site-extension/Content/README.md diff --git a/cloud-tooling/azure-site-extension/tools/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/tools/install.cmd rename to cloud-tooling/azure-site-extension/Content/install.cmd diff --git a/cloud-tooling/azure-site-extension/tools/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1 similarity index 100% rename from cloud-tooling/azure-site-extension/tools/install.ps1 rename to cloud-tooling/azure-site-extension/Content/install.ps1 diff --git a/cloud-tooling/azure-site-extension/tools/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/tools/uninstall.cmd rename to cloud-tooling/azure-site-extension/Content/uninstall.cmd diff --git a/cloud-tooling/azure-site-extension/publish.sh b/cloud-tooling/azure-site-extension/publish.sh deleted file mode 100755 index 4da6e28765..0000000000 --- a/cloud-tooling/azure-site-extension/publish.sh +++ /dev/null @@ -1,12 +0,0 @@ -# This is just a simple shell script that will later be -# used as a template for a GHA job for -# azure-site-extension site extension uploads. - -# Dependencies: .Net 5 and up or .Net Core, Mono, and the Nuget CLI. -NUGET_API_KEY=$1 -NUGET_SOURCE=$2 -VERSION=$(cat version.txt) -NUSPEC_GENERATED="NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nuspec" -sed "s/{VERSION}/${VERSION}/g" NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec > "${NUSPEC_GENERATED}" -nuget pack "${NUSPEC_GENERATED}" -dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} diff --git a/cloud-tooling/azure-site-extension/version.txt b/cloud-tooling/azure-site-extension/version.txt deleted file mode 100644 index 4044f90867..0000000000 --- a/cloud-tooling/azure-site-extension/version.txt +++ /dev/null @@ -1 +0,0 @@ -12.0.0 From 1d0667750a23b192488e6ad744adbd9d0cdad962 Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 15:34:32 -0400 Subject: [PATCH 05/40] chore: Added env vars for publish step, and added node options Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 20 +++++++++---------- .../Content/applicationHost.xdt | 3 +-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index a41b4edf5f..546b8652b2 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -43,16 +43,21 @@ jobs: 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}}-${{ matrix.node-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 Content newrelic@${{ env.AGENT_VERSION }} + run: | + npm i --prefix Content newrelic@${{ env.AGENT_VERSION }} + echo "Agent installed" - name: Configure package files working-directory: cloud-tooling/azure-site-extension @@ -61,13 +66,7 @@ jobs: - name: Create bundle working-directory: cloud-tooling/azure-site-extension - run: | - echo "Going to list Content directory contents" - Get-ChildItem -Path Content/* -Recurse -Force - echo "===================" - nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" - echo "Going to list directory contents" - Get-ChildItem -Path .\*.* -Recurse -Force + run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" - name: Archive package for verification uses: actions/upload-artifact@v4 @@ -76,7 +75,6 @@ jobs: path: cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nupkg # - name: publish_package +# working-directory: cloud-tooling/azure-site-extension # run: | -# NUGET_API_KEY=$1 -# NUGET_SOURCE=$2 -# dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} +# dotnet nuget push "${{ env.PACKAGE_FILENAME }}.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ secrets.NUGET_SOURCE }} diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt index 727bea69a9..9ad2f97f7c 100644 --- a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt +++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt @@ -3,8 +3,7 @@ - - + From 3c5d19706e4cbaed17bd8d6780e6a923ccd392a7 Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 16:01:34 -0400 Subject: [PATCH 06/40] chore: Edited README.md Signed-off-by: mrickard --- .../azure-site-extension/Content/README.md | 86 ++----------------- 1 file changed, 5 insertions(+), 81 deletions(-) diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index 960e74e8fb..2dbee140c0 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -1,90 +1,14 @@ # 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 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/). +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 -This extension is designed for Node applications running on Azure Windows compute resources. +Applying the site extension will install the New Relic Node agent. -**Note:** Make sure that the target application is stopped prior to installing the extension. +## Configuration -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` -- Click on the `Accept Legal Terms` link -- Click `OK` on the bottom left of the page -- Again, click `OK` on the bottom left of the page. This will begin installation of the extension +The Node agent can be started by adding `-r newrelic` to your application's `start` command, or by adding `-r newrelic` to the `NODE_OPTIONS` environment variable. -Once installed, the extension creates the following artifacts: -- Folder: `C:\home\node_modules\newrelic` - Contains the Node agent artifacts -- XDT: `applicationHost.xdt` that will add the necessary environment variable on application startup +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/). -If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.WebSites.Extension.NodeAgent\install.log`. - -## Getting Started - -Once the site extension is installed, you'll need to manually enter two configuration items before restarting your application: -- On the options listed on the left, scroll down to "Configuration" located under the `Settings` category -- On the configuration page, add the following two app settings: - - `NEW_RELIC_LICENSE_KEY` - Your New Relic license key value - - `NEW_RELIC_APP_NAME` - The name you wish your application to show up as in the New Relic Platform - -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. - -## Building - -### Installing Dependencies (for MacOS and Linux) - -- Download and install the latest version of [Mono](https://www.mono-project.com/download/stable/) -- Download `nuget.exe`: `sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe` -- Create an alias in your .bashrc or .zshrc for mono: `alias nuget="mono /usr/local/bin/nuget.exe"` -- 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. -- Restart your shell and execute `nuget` to verify your mono installation and `dotnet` to verify your .Net installation. - -References: -- https://www.wiliam.com.au/wiliam-blog/creating-a-nuget-package -- https://learn.microsoft.com/en-au/nuget/install-nuget-client-tools#nugetexe-cli - -### Publishing the Package - -#### Publishing the Package with the Script (recommended) -- Your nuget package version is hardcoded in `version.txt`, update the file to change the version number. -- Run `./publish.sh `: this will create the NuGet package and upload to the target repository -- The parameters for `publish.sh` are the following: - - `NUGET_API_KEY` - API key for uploading artifacts to the target NuGet repository - - `NUGET_SOURCE` - Target NuGet repository (https://api.nuget.org/v3/index.json is the main, public URL) - -#### Manually publishing the Package - -- Change into the folder where the `.nuget` file exists -- Replace `{VERSION}` in `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` with a version number you want to push. (DO NOT COMMIT THIS CHANGE) -- Execute: `nuget pack NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` -- This will create a package with the name: `NewRelic.Azure.WebSites.Extension.NodeAgent.VERSION.nupkg` -- 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) - -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. - -## Testing - -It is recommended you use a personnel repository created in [MyGet](https://www.myget.org/). - -Upload the nuget package then set up an app config variable in Azure: -- `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 - -In Azure, when you browse to `Development Tools` > `Extensions`, you will see a list of Nuget packages in your private repository. - - -## 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](https://learn.microsoft.com/en-us/nuget/reference/nuspec) -- `publish.sh` - Simple script to package the script and upload to the Nuget repository -- `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 downloads the agent bundle and installs it to the proper location on the host -- `Content/uninstall.cmd` - Simple batch file that will remove the Node installtion artifacts when the extension is removed From 71a8f623eec729d8599a21f5ec57d3fa479cc509 Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 16:02:54 -0400 Subject: [PATCH 07/40] chore: Updated name of publish step in workflow Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 546b8652b2..f3a047e737 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -74,7 +74,7 @@ jobs: name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }} path: cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nupkg -# - name: publish_package +# - 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 }} From 81cfe2e9db62bce5b2a1218465ba30e884ab441c Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 16:25:49 -0400 Subject: [PATCH 08/40] chore: Restored Node 18 publishing Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index f3a047e737..90e2a86f91 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -30,7 +30,7 @@ jobs: strategy: matrix: - node-version: ['20.x'] # Node 22 isn't yet available on Azure + node-version: ['18.x', '20.x'] # Node 22 isn't yet available for Windows apps in Azure steps: - uses: actions/checkout@v4 From 36b1d9b537198a4863b3a5e269e61dd0ea408d47 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:39:20 -0500 Subject: [PATCH 09/40] remove files that exist in another pr and add application host files --- .../Content/applicationHost.xdt | 3 ++ .../azure-site-extension/Content/install.cmd | 8 ---- .../azure-site-extension/Content/install.ps1 | 43 ------------------- .../Content/scmApplicationHost.xdt | 5 +++ .../Content/uninstall.cmd | 7 --- 5 files changed, 8 insertions(+), 58 deletions(-) delete mode 100644 cloud-tooling/azure-site-extension/Content/install.cmd delete mode 100644 cloud-tooling/azure-site-extension/Content/install.ps1 create mode 100644 cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt delete mode 100644 cloud-tooling/azure-site-extension/Content/uninstall.cmd diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt index 9ad2f97f7c..2ac781f5df 100644 --- a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt +++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt @@ -3,6 +3,9 @@ + + + diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd deleted file mode 100644 index 1618af677e..0000000000 --- a/cloud-tooling/azure-site-extension/Content/install.cmd +++ /dev/null @@ -1,8 +0,0 @@ -:: Copyright 2022 New Relic Corporation. All rights reserved. -:: SPDX-License-Identifier: Apache-2.0 - -@echo off - -powershell.exe -ExecutionPolicy RemoteSigned -File install.ps1 - -echo %ERRORLEVEL% diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1 deleted file mode 100644 index 767fc6802e..0000000000 --- a/cloud-tooling/azure-site-extension/Content/install.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -############################################################ -# Copyright 2022 New Relic Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -############################################################ - -# Install.ps1 -# -# This version uses npm install, which we're not going to want to do -# in the released version - -try { - WriteToInstallLog "Start executing install.ps1" - - # Selects the agent version - $agentVersion = "latest" - if ($env:NEWRELIC_AGENT_VERSION_OVERRIDE -ne $null) { - $agentVersion = $env:NEWRELIC_AGENT_VERSION_OVERRIDE.ToString() - WriteToInstallLog "Installing Node agent version $agentVersion" - } else { - WriteToInstallLog "Installing the latest Node agent" - } - - WriteToInstallLog "Executing npm install newrelic@latest" - npm install newrelic@latest - - WriteToInstallLog "End executing install.ps1." - WriteToInstallLog "-----------------------------" - exit $LASTEXITCODE -} -catch -{ - $errorMessage = $_.Exception.Message - $errorLine = $_.InvocationInfo.ScriptLineNumber - WriteToInstallLog "Error at line $errorLine : $errorMessage" - WriteToInstallLog "Explicitly adding node to path" - SET PATH=C:\Program Files\Nodejs;%PATH% - WriteToInstallLog "Executing npm install newrelic@latest" - npm install newrelic@latest - WriteToInstallLog "End executing install.ps1." - WriteToInstallLog "-----------------------------" - - exit $LASTEXITCODE -} diff --git a/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt b/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt new file mode 100644 index 0000000000..6ac1b18678 --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt @@ -0,0 +1,5 @@ + + + + diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd deleted file mode 100644 index 2a88ef5f3b..0000000000 --- a/cloud-tooling/azure-site-extension/Content/uninstall.cmd +++ /dev/null @@ -1,7 +0,0 @@ -:: Copyright 2022 New Relic Corporation. All rights reserved. -:: SPDX-License-Identifier: Apache-2.0 - -SET NEW_RELIC_FOLDER="%HOME%\node_modules/newrelic" -IF EXIST %NEW_RELIC_FOLDER% ( - npm uninstall newrelic -) From 92243ff98cc7aceb8b604c392148d932ebf1c871 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:46:46 -0500 Subject: [PATCH 10/40] Add site extension file and action to update site extension version --- .github/workflows/azure-site-extension.yml | 7 +++++++ cloud-tooling/azure-site-extension/.gitignore | 1 + 2 files changed, 8 insertions(+) create mode 100644 cloud-tooling/azure-site-extension/.gitignore diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 90e2a86f91..8ac5699ddc 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -64,6 +64,13 @@ jobs: run: | (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec + - name: Update siteextensions.json + working-directory: cloud-tooling/azure-site-extension + run: | + $siteext_content = Get-Content "siteextension.json" -Raw | ConvertFrom-Json + $siteext_content.version = "${{ env.AGENT_VERSION }}" + $siteext_content | ConvertTo-Json -Depth 10 | Set-Content "siteextension.json" + - name: Create bundle working-directory: cloud-tooling/azure-site-extension run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" diff --git a/cloud-tooling/azure-site-extension/.gitignore b/cloud-tooling/azure-site-extension/.gitignore new file mode 100644 index 0000000000..5bdf479bc9 --- /dev/null +++ b/cloud-tooling/azure-site-extension/.gitignore @@ -0,0 +1 @@ +NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg From 40306fdfc40fcee05a5eadee94ccb48e79bd6944 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:47:40 -0500 Subject: [PATCH 11/40] Add site extension file --- .../azure-site-extension/Content/siteextension.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 cloud-tooling/azure-site-extension/Content/siteextension.json diff --git a/cloud-tooling/azure-site-extension/Content/siteextension.json b/cloud-tooling/azure-site-extension/Content/siteextension.json new file mode 100644 index 0000000000..bbb6dfbbca --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/siteextension.json @@ -0,0 +1,9 @@ +{ + "id": "New Relic Node Agent Site Extension", + "title": "New Relic Node Agent Site Extension", + "description": "A New Relic Node Agent site extension for Azure Web Apps.", + "version": "12.0.0", + "authors": ["New Relic"], + "tags": ["Node", "Azure", "Extension"], + "type": "WebRoot" +} From d6f10fd72212198836fc85c4dba9e95507c50ee6 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:21:20 -0500 Subject: [PATCH 12/40] Add readme and remove unnecessary site extension file --- .github/workflows/azure-site-extension.yml | 7 ---- .../azure-site-extension/Content/README.md | 36 +++++++++++++++++-- .../Content/siteextension.json | 9 ----- 3 files changed, 34 insertions(+), 18 deletions(-) delete mode 100644 cloud-tooling/azure-site-extension/Content/siteextension.json diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 8ac5699ddc..90e2a86f91 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -64,13 +64,6 @@ jobs: run: | (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec - - name: Update siteextensions.json - working-directory: cloud-tooling/azure-site-extension - run: | - $siteext_content = Get-Content "siteextension.json" -Raw | ConvertFrom-Json - $siteext_content.version = "${{ env.AGENT_VERSION }}" - $siteext_content | ConvertTo-Json -Depth 10 | Set-Content "siteextension.json" - - name: Create bundle working-directory: cloud-tooling/azure-site-extension run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index 2dbee140c0..fb4219b004 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -6,9 +6,41 @@ This project creates an Azure site extension that automatically installs the New Applying the site extension will install the New Relic Node agent. -## Configuration +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 Node agent can be started by adding `-r newrelic` to your application's `start` command, or by adding `-r newrelic` to the `NODE_OPTIONS` environment variable. +If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.Websites.Extension.NodeAgent\install.log`. +## 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 two configuration items 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 + - `NEW_RELIC_APP_NAME` - The Node agent will automatically set the application name to the value of `WEBSITE_SITE_NAME` in azure for you application but you can override that by setting the `NEW_RELIC_APP_NAME` environment variable. + +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 installtion artifacts when the extension is removed + + diff --git a/cloud-tooling/azure-site-extension/Content/siteextension.json b/cloud-tooling/azure-site-extension/Content/siteextension.json deleted file mode 100644 index bbb6dfbbca..0000000000 --- a/cloud-tooling/azure-site-extension/Content/siteextension.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "New Relic Node Agent Site Extension", - "title": "New Relic Node Agent Site Extension", - "description": "A New Relic Node Agent site extension for Azure Web Apps.", - "version": "12.0.0", - "authors": ["New Relic"], - "tags": ["Node", "Azure", "Extension"], - "type": "WebRoot" -} From 2ba039a39b84dd22f2fc071876bb1017c058fa2e Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:48:06 -0500 Subject: [PATCH 13/40] uncomment publish step --- .github/workflows/azure-site-extension.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 90e2a86f91..ced47b541f 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -74,7 +74,7 @@ jobs: 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 }} + - 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 }} From 4e1d6c2397cc1ddbb61dcf61970d29c40bfebebc Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:01:28 -0500 Subject: [PATCH 14/40] Update .github/workflows/azure-site-extension.yml Co-authored-by: James Sumners --- .github/workflows/azure-site-extension.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index ced47b541f..fbc97ff077 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -13,15 +13,15 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v4 - - name: Setup dotnet '6.0.x' - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '6.0.x' - - name: Display dotnet version - run: dotnet --version - - name: Display NuGet version - run: nuget ? + - uses: actions/checkout@v4 + - name: Setup dotnet '6.0.x' + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.0.x' + - name: Display dotnet version + run: dotnet --version + - name: Display NuGet version + run: nuget ? create_extension_bundle: runs-on: windows-latest From 0ddef71c553cc89ba1595ffcb5eabca5bfb3a2ca Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:01:53 -0500 Subject: [PATCH 15/40] Update .github/workflows/azure-site-extension.yml Co-authored-by: James Sumners --- .github/workflows/azure-site-extension.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index fbc97ff077..531085e46f 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -4,8 +4,6 @@ on: workflow_dispatch: env: - # Enable versioned runner quiet mode to make CI output easier to read: - # OUTPUT_MODE: quiet SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec' jobs: From ff619cfaefd95a6b66e00de9246c813237279c3e Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:52:07 -0500 Subject: [PATCH 16/40] remove node versions --- .github/workflows/azure-site-extension.yml | 9 +++++---- .../NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 531085e46f..b79286776a 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: - node-version: ['18.x', '20.x'] # Node 22 isn't yet available for Windows apps in Azure + node-version: ['lts/*'] steps: - uses: actions/checkout@v4 @@ -44,7 +44,7 @@ jobs: - name: Set package filename run: | - echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}-${{ matrix.node-version }}" | Out-File -FilePath $env:GITHUB_ENV -Append + 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: | @@ -54,18 +54,19 @@ jobs: - name: Install agent working-directory: cloud-tooling/azure-site-extension/Content run: | - npm i --prefix Content newrelic@${{ env.AGENT_VERSION }} + 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 }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec + (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: diff --git a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec index 0a1359b3e5..d2d5d91f08 100644 --- a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec +++ b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec @@ -2,8 +2,8 @@ NewRelic.Azure.WebSites.Extension.NodeAgent - {VERSION}-{NODE_VERSION} - New Relic Node Agent {VERSION} (Node.js {NODE_VERSION}) + {VERSION} + New Relic Node Agent {VERSION} New Relic Apache-2.0 https://github.com/newrelic/node-newrelic From 4187e23ab841afab5853e60c1d49289a69a32512 Mon Sep 17 00:00:00 2001 From: mrickard Date: Mon, 26 Aug 2024 12:13:48 -0400 Subject: [PATCH 17/40] chore: Included .NET setup in site extension bundle job Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index b79286776a..c568f8aa3b 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -7,24 +7,8 @@ env: SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec' jobs: - setup_tools: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v4 - - name: Setup dotnet '6.0.x' - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '6.0.x' - - name: Display dotnet version - run: dotnet --version - - name: Display NuGet version - run: nuget ? - create_extension_bundle: runs-on: windows-latest - needs: - - setup_tools strategy: matrix: @@ -32,6 +16,12 @@ jobs: 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: From 81db08e89a0e97e2f48c4e02620cddcdad7f021c Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 8 Aug 2024 16:01:46 -0400 Subject: [PATCH 18/40] feat: Testing tooling available to windows runners Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/azure-site-extension.yml diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml new file mode 100644 index 0000000000..9a99f4224f --- /dev/null +++ b/.github/workflows/azure-site-extension.yml @@ -0,0 +1,20 @@ +name: Azure Site Extension + +on: + workflow_dispatch: + +env: + # Enable versioned runner quiet mode to make CI output easier to read: + OUTPUT_MODE: quiet + +jobs: + test-environment: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - name: Try to run NuGet + run: nuget + - name: Try to run dotnet + run: dotnet + From e2d2463ad17439156eaa5266dee6c16de86d5e31 Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 8 Aug 2024 16:42:16 -0400 Subject: [PATCH 19/40] chore: Added and debugged dotnet setup --- .github/workflows/azure-site-extension.yml | 86 +++++++++++++++-- .../Content/applicationHost.xdt | 11 +++ .../azure-site-extension/Content/install.cmd | 8 ++ .../azure-site-extension/Content/install.ps1 | 43 +++++++++ .../Content/uninstall.cmd | 7 ++ ....Azure.WebSites.Extension.NodeAgent.nuspec | 24 +++++ cloud-tooling/azure-site-extension/README.md | 90 ++++++++++++++++++ cloud-tooling/azure-site-extension/icon.png | Bin 0 -> 5559 bytes cloud-tooling/azure-site-extension/publish.sh | 12 +++ .../azure-site-extension/version.txt | 1 + 10 files changed, 276 insertions(+), 6 deletions(-) create mode 100644 cloud-tooling/azure-site-extension/Content/applicationHost.xdt create mode 100644 cloud-tooling/azure-site-extension/Content/install.cmd create mode 100644 cloud-tooling/azure-site-extension/Content/install.ps1 create mode 100644 cloud-tooling/azure-site-extension/Content/uninstall.cmd create mode 100644 cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec create mode 100644 cloud-tooling/azure-site-extension/README.md create mode 100644 cloud-tooling/azure-site-extension/icon.png create mode 100755 cloud-tooling/azure-site-extension/publish.sh create mode 100644 cloud-tooling/azure-site-extension/version.txt diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 9a99f4224f..4e25a59ae5 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -5,16 +5,90 @@ on: env: # Enable versioned runner quiet mode to make CI output easier to read: - OUTPUT_MODE: quiet + # OUTPUT_MODE: quiet + SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec' jobs: - test-environment: + setup_tools: runs-on: windows-latest steps: - uses: actions/checkout@v4 - - name: Try to run NuGet - run: nuget - - name: Try to run dotnet - run: dotnet + - name: Setup dotnet '6.0.x' + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.0.x' + - name: Display dotnet version + run: dotnet --version + - name: Display NuGet version + run: nuget ? + + create_extension_bundle: + runs-on: windows-latest + needs: + - setup_tools + + strategy: + matrix: + node-version: ['20.x'] # Node 22 isn't yet available on Azure + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - 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}}.${{ matrix.node-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 }}" +# echo ("PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}.${{ matrix.node-version }}") >> $env:GITHUB_ENV + - name: install_agent + run: | + cd "cloud-tooling/azure-site-extension/Content" + pwd + npm i newrelic@${{ env.AGENT_VERSION }} + +# - name: configure_package +# run: | +# cd .. +# (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', ${{ env.AGENT_VERSION }}).Replace('{NODE_VERSION}', ${{ matrix.node-version }}) | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec +# get-content ${{ env.SPEC_FILE_TEMPLATE }} | %{$_ -replace "{VERSION}","${{ env.AGENT_VERSION }}"} >> ${{NUSPEC_GENERATED}} + +# - name: pack +# run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" -OutputDirectory=./azure-site-extension/dist +# - name: Archive package for verification +# uses: actions/upload-artifact@v4 +# with: +# name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }} +# path: ./azure-site-extension/dist/ + +# - name: publish_package +# run: | +# NUGET_API_KEY=$1 +# NUGET_SOURCE=$2 +# dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} +# + + +# - name: GitHub Example +# id: step_one +# run: | +# $env:npm_agent_version = npm view newrelic version +# echo "agent version? $env:npm_agent_version" +# echo "AGENT_VERSION=$env:AGENT_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append +# - name: Use the value +# id: step_two +# run: | +# echo "action state: ${{ env.action_state }}" # This will output 'yellow' +# echo "action state no-append: ${{ env.action_state_no_append }}" +# echo "AGENT_VERSION from shell: $env:AGENT_VERSION" +# echo "AGENT_VERSION from GitHub Actions: ${{ env.AGENT_VERSION }}" diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt new file mode 100644 index 0000000000..727bea69a9 --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd new file mode 100644 index 0000000000..1618af677e --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/install.cmd @@ -0,0 +1,8 @@ +:: Copyright 2022 New Relic Corporation. All rights reserved. +:: SPDX-License-Identifier: Apache-2.0 + +@echo off + +powershell.exe -ExecutionPolicy RemoteSigned -File install.ps1 + +echo %ERRORLEVEL% diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1 new file mode 100644 index 0000000000..767fc6802e --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/install.ps1 @@ -0,0 +1,43 @@ +############################################################ +# Copyright 2022 New Relic Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +############################################################ + +# Install.ps1 +# +# This version uses npm install, which we're not going to want to do +# in the released version + +try { + WriteToInstallLog "Start executing install.ps1" + + # Selects the agent version + $agentVersion = "latest" + if ($env:NEWRELIC_AGENT_VERSION_OVERRIDE -ne $null) { + $agentVersion = $env:NEWRELIC_AGENT_VERSION_OVERRIDE.ToString() + WriteToInstallLog "Installing Node agent version $agentVersion" + } else { + WriteToInstallLog "Installing the latest Node agent" + } + + WriteToInstallLog "Executing npm install newrelic@latest" + npm install newrelic@latest + + WriteToInstallLog "End executing install.ps1." + WriteToInstallLog "-----------------------------" + exit $LASTEXITCODE +} +catch +{ + $errorMessage = $_.Exception.Message + $errorLine = $_.InvocationInfo.ScriptLineNumber + WriteToInstallLog "Error at line $errorLine : $errorMessage" + WriteToInstallLog "Explicitly adding node to path" + SET PATH=C:\Program Files\Nodejs;%PATH% + WriteToInstallLog "Executing npm install newrelic@latest" + npm install newrelic@latest + WriteToInstallLog "End executing install.ps1." + WriteToInstallLog "-----------------------------" + + exit $LASTEXITCODE +} diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd new file mode 100644 index 0000000000..2a88ef5f3b --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/uninstall.cmd @@ -0,0 +1,7 @@ +:: Copyright 2022 New Relic Corporation. All rights reserved. +:: SPDX-License-Identifier: Apache-2.0 + +SET NEW_RELIC_FOLDER="%HOME%\node_modules/newrelic" +IF EXIST %NEW_RELIC_FOLDER% ( + npm uninstall newrelic +) diff --git a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec new file mode 100644 index 0000000000..0a1359b3e5 --- /dev/null +++ b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec @@ -0,0 +1,24 @@ + + + + NewRelic.Azure.WebSites.Extension.NodeAgent + {VERSION}-{NODE_VERSION} + New Relic Node Agent {VERSION} (Node.js {NODE_VERSION}) + New Relic + Apache-2.0 + https://github.com/newrelic/node-newrelic + true + This extension adds the New Relic Node Agent to your Azure WebSite. + https://newrelic.com/static-assets/images/icons/avatar-newrelic.png + images\icon.png + New Relic, Inc., 2024 + AzureSiteExtension + + + + + + + + + diff --git a/cloud-tooling/azure-site-extension/README.md b/cloud-tooling/azure-site-extension/README.md new file mode 100644 index 0000000000..960e74e8fb --- /dev/null +++ b/cloud-tooling/azure-site-extension/README.md @@ -0,0 +1,90 @@ +# 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 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/). + +## Installation + +This extension is designed for Node applications running on Azure Windows compute resources. + +**Note:** Make sure that the target application is stopped prior to installing the extension. + +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` +- Click on the `Accept Legal Terms` link +- Click `OK` on the bottom left of the page +- Again, click `OK` on the bottom left of the page. This will begin installation of the extension + +Once installed, the extension creates the following artifacts: +- Folder: `C:\home\node_modules\newrelic` - Contains the Node agent artifacts +- XDT: `applicationHost.xdt` that will add the necessary environment variable on application startup + +If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.WebSites.Extension.NodeAgent\install.log`. + +## Getting Started + +Once the site extension is installed, you'll need to manually enter two configuration items before restarting your application: +- On the options listed on the left, scroll down to "Configuration" located under the `Settings` category +- On the configuration page, add the following two app settings: + - `NEW_RELIC_LICENSE_KEY` - Your New Relic license key value + - `NEW_RELIC_APP_NAME` - The name you wish your application to show up as in the New Relic Platform + +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. + +## Building + +### Installing Dependencies (for MacOS and Linux) + +- Download and install the latest version of [Mono](https://www.mono-project.com/download/stable/) +- Download `nuget.exe`: `sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe` +- Create an alias in your .bashrc or .zshrc for mono: `alias nuget="mono /usr/local/bin/nuget.exe"` +- 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. +- Restart your shell and execute `nuget` to verify your mono installation and `dotnet` to verify your .Net installation. + +References: +- https://www.wiliam.com.au/wiliam-blog/creating-a-nuget-package +- https://learn.microsoft.com/en-au/nuget/install-nuget-client-tools#nugetexe-cli + +### Publishing the Package + +#### Publishing the Package with the Script (recommended) +- Your nuget package version is hardcoded in `version.txt`, update the file to change the version number. +- Run `./publish.sh `: this will create the NuGet package and upload to the target repository +- The parameters for `publish.sh` are the following: + - `NUGET_API_KEY` - API key for uploading artifacts to the target NuGet repository + - `NUGET_SOURCE` - Target NuGet repository (https://api.nuget.org/v3/index.json is the main, public URL) + +#### Manually publishing the Package + +- Change into the folder where the `.nuget` file exists +- Replace `{VERSION}` in `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` with a version number you want to push. (DO NOT COMMIT THIS CHANGE) +- Execute: `nuget pack NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` +- This will create a package with the name: `NewRelic.Azure.WebSites.Extension.NodeAgent.VERSION.nupkg` +- 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) + +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. + +## Testing + +It is recommended you use a personnel repository created in [MyGet](https://www.myget.org/). + +Upload the nuget package then set up an app config variable in Azure: +- `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 + +In Azure, when you browse to `Development Tools` > `Extensions`, you will see a list of Nuget packages in your private repository. + + +## 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](https://learn.microsoft.com/en-us/nuget/reference/nuspec) +- `publish.sh` - Simple script to package the script and upload to the Nuget repository +- `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 downloads the agent bundle and installs it to the proper location on the host +- `Content/uninstall.cmd` - Simple batch file that will remove the Node installtion artifacts when the extension is removed diff --git a/cloud-tooling/azure-site-extension/icon.png b/cloud-tooling/azure-site-extension/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ec5bab479fd89bd3cc13deb0f01a1ffaf39ca3dd GIT binary patch literal 5559 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 FV1h4Kaw7l$ literal 0 HcmV?d00001 diff --git a/cloud-tooling/azure-site-extension/publish.sh b/cloud-tooling/azure-site-extension/publish.sh new file mode 100755 index 0000000000..4da6e28765 --- /dev/null +++ b/cloud-tooling/azure-site-extension/publish.sh @@ -0,0 +1,12 @@ +# This is just a simple shell script that will later be +# used as a template for a GHA job for +# azure-site-extension site extension uploads. + +# Dependencies: .Net 5 and up or .Net Core, Mono, and the Nuget CLI. +NUGET_API_KEY=$1 +NUGET_SOURCE=$2 +VERSION=$(cat version.txt) +NUSPEC_GENERATED="NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nuspec" +sed "s/{VERSION}/${VERSION}/g" NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec > "${NUSPEC_GENERATED}" +nuget pack "${NUSPEC_GENERATED}" +dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} diff --git a/cloud-tooling/azure-site-extension/version.txt b/cloud-tooling/azure-site-extension/version.txt new file mode 100644 index 0000000000..4044f90867 --- /dev/null +++ b/cloud-tooling/azure-site-extension/version.txt @@ -0,0 +1 @@ +12.0.0 From 96dc84e88820d26abbb009c759a955655da9e703 Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 15 Aug 2024 12:05:04 -0400 Subject: [PATCH 20/40] fix: Fixed package creation and nuspec config Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 43 +++++++------------ .../{Content => tools}/install.cmd | 0 .../{Content => tools}/install.ps1 | 0 .../{Content => tools}/uninstall.cmd | 0 4 files changed, 15 insertions(+), 28 deletions(-) rename cloud-tooling/azure-site-extension/{Content => tools}/install.cmd (100%) rename cloud-tooling/azure-site-extension/{Content => tools}/install.ps1 (100%) rename cloud-tooling/azure-site-extension/{Content => tools}/uninstall.cmd (100%) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 4e25a59ae5..d45f1633e3 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup dotnet '6.0.x' - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: '6.0.x' - name: Display dotnet version @@ -49,46 +49,33 @@ jobs: run: | echo "Agent version: ${{ env.AGENT_VERSION }}" echo "Package filename: ${{ env.PACKAGE_FILENAME }}" -# echo ("PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}.${{ matrix.node-version }}") >> $env:GITHUB_ENV - - name: install_agent + - name: Install agent run: | cd "cloud-tooling/azure-site-extension/Content" - pwd npm i newrelic@${{ env.AGENT_VERSION }} -# - name: configure_package -# run: | -# cd .. -# (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', ${{ env.AGENT_VERSION }}).Replace('{NODE_VERSION}', ${{ matrix.node-version }}) | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec + - name: Configure package files + run: | + pwd + (Get-Content cloud-tooling/azure-site-extension/${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nuspec # get-content ${{ env.SPEC_FILE_TEMPLATE }} | %{$_ -replace "{VERSION}","${{ env.AGENT_VERSION }}"} >> ${{NUSPEC_GENERATED}} -# - name: pack -# run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" -OutputDirectory=./azure-site-extension/dist + - name: Create bundle + run: | + pwd + cd cloud-tooling/azure-site-extension/ + nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" + echo "Going to list directory contents" + Get-ChildItem -Path .\*.* -Recurse -Force + # - name: Archive package for verification # uses: actions/upload-artifact@v4 # with: # name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }} -# path: ./azure-site-extension/dist/ +# path: cloud-tooling/azure-site-extension/.* # - name: publish_package # run: | # NUGET_API_KEY=$1 # NUGET_SOURCE=$2 # dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} -# - - -# - name: GitHub Example -# id: step_one -# run: | -# $env:npm_agent_version = npm view newrelic version -# echo "agent version? $env:npm_agent_version" -# echo "AGENT_VERSION=$env:AGENT_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append -# - name: Use the value -# id: step_two -# run: | -# echo "action state: ${{ env.action_state }}" # This will output 'yellow' -# echo "action state no-append: ${{ env.action_state_no_append }}" -# echo "AGENT_VERSION from shell: $env:AGENT_VERSION" -# echo "AGENT_VERSION from GitHub Actions: ${{ env.AGENT_VERSION }}" - diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/tools/install.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/Content/install.cmd rename to cloud-tooling/azure-site-extension/tools/install.cmd diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/tools/install.ps1 similarity index 100% rename from cloud-tooling/azure-site-extension/Content/install.ps1 rename to cloud-tooling/azure-site-extension/tools/install.ps1 diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/tools/uninstall.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/Content/uninstall.cmd rename to cloud-tooling/azure-site-extension/tools/uninstall.cmd From 708e930a835c442ac3d22715f7f1d3e7deb146a4 Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 15 Aug 2024 17:23:30 -0400 Subject: [PATCH 21/40] fix: Set prefix flag on npm install, replaced cds with working-directory directives Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 29 ++++++++++--------- .../{ => Content}/README.md | 0 .../{tools => Content}/install.cmd | 0 .../{tools => Content}/install.ps1 | 0 .../{tools => Content}/uninstall.cmd | 0 cloud-tooling/azure-site-extension/publish.sh | 12 -------- .../azure-site-extension/version.txt | 1 - 7 files changed, 15 insertions(+), 27 deletions(-) rename cloud-tooling/azure-site-extension/{ => Content}/README.md (100%) rename cloud-tooling/azure-site-extension/{tools => Content}/install.cmd (100%) rename cloud-tooling/azure-site-extension/{tools => Content}/install.ps1 (100%) rename cloud-tooling/azure-site-extension/{tools => Content}/uninstall.cmd (100%) delete mode 100755 cloud-tooling/azure-site-extension/publish.sh delete mode 100644 cloud-tooling/azure-site-extension/version.txt diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index d45f1633e3..a41b4edf5f 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -44,35 +44,36 @@ jobs: $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}}.${{ matrix.node-version }}" | Out-File -FilePath $env:GITHUB_ENV -Append + run: | + echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}-${{ matrix.node-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 - run: | - cd "cloud-tooling/azure-site-extension/Content" - npm i newrelic@${{ env.AGENT_VERSION }} + working-directory: cloud-tooling/azure-site-extension/Content + run: npm i --prefix Content newrelic@${{ env.AGENT_VERSION }} - name: Configure package files + working-directory: cloud-tooling/azure-site-extension run: | - pwd - (Get-Content cloud-tooling/azure-site-extension/${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nuspec -# get-content ${{ env.SPEC_FILE_TEMPLATE }} | %{$_ -replace "{VERSION}","${{ env.AGENT_VERSION }}"} >> ${{NUSPEC_GENERATED}} + (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec - name: Create bundle + working-directory: cloud-tooling/azure-site-extension run: | - pwd - cd cloud-tooling/azure-site-extension/ + echo "Going to list Content directory contents" + Get-ChildItem -Path Content/* -Recurse -Force + echo "===================" nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" echo "Going to list directory contents" Get-ChildItem -Path .\*.* -Recurse -Force -# - 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/.* + - 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_package # run: | diff --git a/cloud-tooling/azure-site-extension/README.md b/cloud-tooling/azure-site-extension/Content/README.md similarity index 100% rename from cloud-tooling/azure-site-extension/README.md rename to cloud-tooling/azure-site-extension/Content/README.md diff --git a/cloud-tooling/azure-site-extension/tools/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/tools/install.cmd rename to cloud-tooling/azure-site-extension/Content/install.cmd diff --git a/cloud-tooling/azure-site-extension/tools/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1 similarity index 100% rename from cloud-tooling/azure-site-extension/tools/install.ps1 rename to cloud-tooling/azure-site-extension/Content/install.ps1 diff --git a/cloud-tooling/azure-site-extension/tools/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd similarity index 100% rename from cloud-tooling/azure-site-extension/tools/uninstall.cmd rename to cloud-tooling/azure-site-extension/Content/uninstall.cmd diff --git a/cloud-tooling/azure-site-extension/publish.sh b/cloud-tooling/azure-site-extension/publish.sh deleted file mode 100755 index 4da6e28765..0000000000 --- a/cloud-tooling/azure-site-extension/publish.sh +++ /dev/null @@ -1,12 +0,0 @@ -# This is just a simple shell script that will later be -# used as a template for a GHA job for -# azure-site-extension site extension uploads. - -# Dependencies: .Net 5 and up or .Net Core, Mono, and the Nuget CLI. -NUGET_API_KEY=$1 -NUGET_SOURCE=$2 -VERSION=$(cat version.txt) -NUSPEC_GENERATED="NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nuspec" -sed "s/{VERSION}/${VERSION}/g" NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec > "${NUSPEC_GENERATED}" -nuget pack "${NUSPEC_GENERATED}" -dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} diff --git a/cloud-tooling/azure-site-extension/version.txt b/cloud-tooling/azure-site-extension/version.txt deleted file mode 100644 index 4044f90867..0000000000 --- a/cloud-tooling/azure-site-extension/version.txt +++ /dev/null @@ -1 +0,0 @@ -12.0.0 From 6ed7c93c5b4069170d14ba6c5383b883e6f26d6c Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 15:34:32 -0400 Subject: [PATCH 22/40] chore: Added env vars for publish step, and added node options Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 20 +++++++++---------- .../Content/applicationHost.xdt | 3 +-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index a41b4edf5f..546b8652b2 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -43,16 +43,21 @@ jobs: 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}}-${{ matrix.node-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 Content newrelic@${{ env.AGENT_VERSION }} + run: | + npm i --prefix Content newrelic@${{ env.AGENT_VERSION }} + echo "Agent installed" - name: Configure package files working-directory: cloud-tooling/azure-site-extension @@ -61,13 +66,7 @@ jobs: - name: Create bundle working-directory: cloud-tooling/azure-site-extension - run: | - echo "Going to list Content directory contents" - Get-ChildItem -Path Content/* -Recurse -Force - echo "===================" - nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" - echo "Going to list directory contents" - Get-ChildItem -Path .\*.* -Recurse -Force + run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" - name: Archive package for verification uses: actions/upload-artifact@v4 @@ -76,7 +75,6 @@ jobs: path: cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nupkg # - name: publish_package +# working-directory: cloud-tooling/azure-site-extension # run: | -# NUGET_API_KEY=$1 -# NUGET_SOURCE=$2 -# dotnet nuget push "NewRelic.Azure.WebSites.Extension.NodeAgent.${VERSION}.nupkg" --api-key ${NUGET_API_KEY} --source ${NUGET_SOURCE} +# dotnet nuget push "${{ env.PACKAGE_FILENAME }}.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ secrets.NUGET_SOURCE }} diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt index 727bea69a9..9ad2f97f7c 100644 --- a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt +++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt @@ -3,8 +3,7 @@ - - + From 214b478529b986555562abd464163aa710308b97 Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 16:01:34 -0400 Subject: [PATCH 23/40] chore: Edited README.md Signed-off-by: mrickard --- .../azure-site-extension/Content/README.md | 86 ++----------------- 1 file changed, 5 insertions(+), 81 deletions(-) diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index 960e74e8fb..2dbee140c0 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -1,90 +1,14 @@ # 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 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/). +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 -This extension is designed for Node applications running on Azure Windows compute resources. +Applying the site extension will install the New Relic Node agent. -**Note:** Make sure that the target application is stopped prior to installing the extension. +## Configuration -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` -- Click on the `Accept Legal Terms` link -- Click `OK` on the bottom left of the page -- Again, click `OK` on the bottom left of the page. This will begin installation of the extension +The Node agent can be started by adding `-r newrelic` to your application's `start` command, or by adding `-r newrelic` to the `NODE_OPTIONS` environment variable. -Once installed, the extension creates the following artifacts: -- Folder: `C:\home\node_modules\newrelic` - Contains the Node agent artifacts -- XDT: `applicationHost.xdt` that will add the necessary environment variable on application startup +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/). -If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.WebSites.Extension.NodeAgent\install.log`. - -## Getting Started - -Once the site extension is installed, you'll need to manually enter two configuration items before restarting your application: -- On the options listed on the left, scroll down to "Configuration" located under the `Settings` category -- On the configuration page, add the following two app settings: - - `NEW_RELIC_LICENSE_KEY` - Your New Relic license key value - - `NEW_RELIC_APP_NAME` - The name you wish your application to show up as in the New Relic Platform - -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. - -## Building - -### Installing Dependencies (for MacOS and Linux) - -- Download and install the latest version of [Mono](https://www.mono-project.com/download/stable/) -- Download `nuget.exe`: `sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe` -- Create an alias in your .bashrc or .zshrc for mono: `alias nuget="mono /usr/local/bin/nuget.exe"` -- 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. -- Restart your shell and execute `nuget` to verify your mono installation and `dotnet` to verify your .Net installation. - -References: -- https://www.wiliam.com.au/wiliam-blog/creating-a-nuget-package -- https://learn.microsoft.com/en-au/nuget/install-nuget-client-tools#nugetexe-cli - -### Publishing the Package - -#### Publishing the Package with the Script (recommended) -- Your nuget package version is hardcoded in `version.txt`, update the file to change the version number. -- Run `./publish.sh `: this will create the NuGet package and upload to the target repository -- The parameters for `publish.sh` are the following: - - `NUGET_API_KEY` - API key for uploading artifacts to the target NuGet repository - - `NUGET_SOURCE` - Target NuGet repository (https://api.nuget.org/v3/index.json is the main, public URL) - -#### Manually publishing the Package - -- Change into the folder where the `.nuget` file exists -- Replace `{VERSION}` in `NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` with a version number you want to push. (DO NOT COMMIT THIS CHANGE) -- Execute: `nuget pack NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec` -- This will create a package with the name: `NewRelic.Azure.WebSites.Extension.NodeAgent.VERSION.nupkg` -- 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) - -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. - -## Testing - -It is recommended you use a personnel repository created in [MyGet](https://www.myget.org/). - -Upload the nuget package then set up an app config variable in Azure: -- `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 - -In Azure, when you browse to `Development Tools` > `Extensions`, you will see a list of Nuget packages in your private repository. - - -## 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](https://learn.microsoft.com/en-us/nuget/reference/nuspec) -- `publish.sh` - Simple script to package the script and upload to the Nuget repository -- `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 downloads the agent bundle and installs it to the proper location on the host -- `Content/uninstall.cmd` - Simple batch file that will remove the Node installtion artifacts when the extension is removed From 6fb73061235ce08b6661d7f306e712c0fab726c9 Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 16:02:54 -0400 Subject: [PATCH 24/40] chore: Updated name of publish step in workflow Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 546b8652b2..f3a047e737 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -74,7 +74,7 @@ jobs: name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }} path: cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nupkg -# - name: publish_package +# - 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 }} From 9350bededbb670cedc8ff3cf993f230ccfa00740 Mon Sep 17 00:00:00 2001 From: mrickard Date: Fri, 16 Aug 2024 16:25:49 -0400 Subject: [PATCH 25/40] chore: Restored Node 18 publishing Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index f3a047e737..90e2a86f91 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -30,7 +30,7 @@ jobs: strategy: matrix: - node-version: ['20.x'] # Node 22 isn't yet available on Azure + node-version: ['18.x', '20.x'] # Node 22 isn't yet available for Windows apps in Azure steps: - uses: actions/checkout@v4 From ab7658e9d65d7f6ce7bb95072e87d092ae1cce09 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:39:20 -0500 Subject: [PATCH 26/40] remove files that exist in another pr and add application host files --- .../Content/applicationHost.xdt | 3 ++ .../azure-site-extension/Content/install.cmd | 8 ---- .../azure-site-extension/Content/install.ps1 | 43 ------------------- .../Content/scmApplicationHost.xdt | 5 +++ .../Content/uninstall.cmd | 7 --- 5 files changed, 8 insertions(+), 58 deletions(-) delete mode 100644 cloud-tooling/azure-site-extension/Content/install.cmd delete mode 100644 cloud-tooling/azure-site-extension/Content/install.ps1 create mode 100644 cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt delete mode 100644 cloud-tooling/azure-site-extension/Content/uninstall.cmd diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt index 9ad2f97f7c..2ac781f5df 100644 --- a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt +++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt @@ -3,6 +3,9 @@ + + + diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd deleted file mode 100644 index 1618af677e..0000000000 --- a/cloud-tooling/azure-site-extension/Content/install.cmd +++ /dev/null @@ -1,8 +0,0 @@ -:: Copyright 2022 New Relic Corporation. All rights reserved. -:: SPDX-License-Identifier: Apache-2.0 - -@echo off - -powershell.exe -ExecutionPolicy RemoteSigned -File install.ps1 - -echo %ERRORLEVEL% diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1 deleted file mode 100644 index 767fc6802e..0000000000 --- a/cloud-tooling/azure-site-extension/Content/install.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -############################################################ -# Copyright 2022 New Relic Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -############################################################ - -# Install.ps1 -# -# This version uses npm install, which we're not going to want to do -# in the released version - -try { - WriteToInstallLog "Start executing install.ps1" - - # Selects the agent version - $agentVersion = "latest" - if ($env:NEWRELIC_AGENT_VERSION_OVERRIDE -ne $null) { - $agentVersion = $env:NEWRELIC_AGENT_VERSION_OVERRIDE.ToString() - WriteToInstallLog "Installing Node agent version $agentVersion" - } else { - WriteToInstallLog "Installing the latest Node agent" - } - - WriteToInstallLog "Executing npm install newrelic@latest" - npm install newrelic@latest - - WriteToInstallLog "End executing install.ps1." - WriteToInstallLog "-----------------------------" - exit $LASTEXITCODE -} -catch -{ - $errorMessage = $_.Exception.Message - $errorLine = $_.InvocationInfo.ScriptLineNumber - WriteToInstallLog "Error at line $errorLine : $errorMessage" - WriteToInstallLog "Explicitly adding node to path" - SET PATH=C:\Program Files\Nodejs;%PATH% - WriteToInstallLog "Executing npm install newrelic@latest" - npm install newrelic@latest - WriteToInstallLog "End executing install.ps1." - WriteToInstallLog "-----------------------------" - - exit $LASTEXITCODE -} diff --git a/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt b/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt new file mode 100644 index 0000000000..6ac1b18678 --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt @@ -0,0 +1,5 @@ + + + + diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd deleted file mode 100644 index 2a88ef5f3b..0000000000 --- a/cloud-tooling/azure-site-extension/Content/uninstall.cmd +++ /dev/null @@ -1,7 +0,0 @@ -:: Copyright 2022 New Relic Corporation. All rights reserved. -:: SPDX-License-Identifier: Apache-2.0 - -SET NEW_RELIC_FOLDER="%HOME%\node_modules/newrelic" -IF EXIST %NEW_RELIC_FOLDER% ( - npm uninstall newrelic -) From 7e5984f621ebc01f0f5c4dd75d7ceb358968134b Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:46:46 -0500 Subject: [PATCH 27/40] Add site extension file and action to update site extension version --- .github/workflows/azure-site-extension.yml | 7 +++++++ cloud-tooling/azure-site-extension/.gitignore | 1 + 2 files changed, 8 insertions(+) create mode 100644 cloud-tooling/azure-site-extension/.gitignore diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 90e2a86f91..8ac5699ddc 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -64,6 +64,13 @@ jobs: run: | (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec + - name: Update siteextensions.json + working-directory: cloud-tooling/azure-site-extension + run: | + $siteext_content = Get-Content "siteextension.json" -Raw | ConvertFrom-Json + $siteext_content.version = "${{ env.AGENT_VERSION }}" + $siteext_content | ConvertTo-Json -Depth 10 | Set-Content "siteextension.json" + - name: Create bundle working-directory: cloud-tooling/azure-site-extension run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" diff --git a/cloud-tooling/azure-site-extension/.gitignore b/cloud-tooling/azure-site-extension/.gitignore new file mode 100644 index 0000000000..5bdf479bc9 --- /dev/null +++ b/cloud-tooling/azure-site-extension/.gitignore @@ -0,0 +1 @@ +NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg From 50de73bb7a49c6e329217737d3d9a73f36711551 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:47:40 -0500 Subject: [PATCH 28/40] Add site extension file --- .../azure-site-extension/Content/siteextension.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 cloud-tooling/azure-site-extension/Content/siteextension.json diff --git a/cloud-tooling/azure-site-extension/Content/siteextension.json b/cloud-tooling/azure-site-extension/Content/siteextension.json new file mode 100644 index 0000000000..bbb6dfbbca --- /dev/null +++ b/cloud-tooling/azure-site-extension/Content/siteextension.json @@ -0,0 +1,9 @@ +{ + "id": "New Relic Node Agent Site Extension", + "title": "New Relic Node Agent Site Extension", + "description": "A New Relic Node Agent site extension for Azure Web Apps.", + "version": "12.0.0", + "authors": ["New Relic"], + "tags": ["Node", "Azure", "Extension"], + "type": "WebRoot" +} From 9c1647b8e50ff7b5a8142e1b9dbef173236f09b2 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:21:20 -0500 Subject: [PATCH 29/40] Add readme and remove unnecessary site extension file --- .github/workflows/azure-site-extension.yml | 7 ---- .../azure-site-extension/Content/README.md | 36 +++++++++++++++++-- .../Content/siteextension.json | 9 ----- 3 files changed, 34 insertions(+), 18 deletions(-) delete mode 100644 cloud-tooling/azure-site-extension/Content/siteextension.json diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 8ac5699ddc..90e2a86f91 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -64,13 +64,6 @@ jobs: run: | (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec - - name: Update siteextensions.json - working-directory: cloud-tooling/azure-site-extension - run: | - $siteext_content = Get-Content "siteextension.json" -Raw | ConvertFrom-Json - $siteext_content.version = "${{ env.AGENT_VERSION }}" - $siteext_content | ConvertTo-Json -Depth 10 | Set-Content "siteextension.json" - - name: Create bundle working-directory: cloud-tooling/azure-site-extension run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index 2dbee140c0..fb4219b004 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -6,9 +6,41 @@ This project creates an Azure site extension that automatically installs the New Applying the site extension will install the New Relic Node agent. -## Configuration +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 Node agent can be started by adding `-r newrelic` to your application's `start` command, or by adding `-r newrelic` to the `NODE_OPTIONS` environment variable. +If the extension fails to install, a log file is created at `C:\home\SiteExtensions\NewRelic.Azure.Websites.Extension.NodeAgent\install.log`. +## 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 two configuration items 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 + - `NEW_RELIC_APP_NAME` - The Node agent will automatically set the application name to the value of `WEBSITE_SITE_NAME` in azure for you application but you can override that by setting the `NEW_RELIC_APP_NAME` environment variable. + +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 installtion artifacts when the extension is removed + + diff --git a/cloud-tooling/azure-site-extension/Content/siteextension.json b/cloud-tooling/azure-site-extension/Content/siteextension.json deleted file mode 100644 index bbb6dfbbca..0000000000 --- a/cloud-tooling/azure-site-extension/Content/siteextension.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "New Relic Node Agent Site Extension", - "title": "New Relic Node Agent Site Extension", - "description": "A New Relic Node Agent site extension for Azure Web Apps.", - "version": "12.0.0", - "authors": ["New Relic"], - "tags": ["Node", "Azure", "Extension"], - "type": "WebRoot" -} From be76fdd4ea98bb7883176d52252fd745f2bfe3c4 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:48:06 -0500 Subject: [PATCH 30/40] uncomment publish step --- .github/workflows/azure-site-extension.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 90e2a86f91..ced47b541f 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -74,7 +74,7 @@ jobs: 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 }} + - 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 }} From 1f184f9c1dc60a0a7d6b989c2abb709f5f982323 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:01:28 -0500 Subject: [PATCH 31/40] Update .github/workflows/azure-site-extension.yml Co-authored-by: James Sumners --- .github/workflows/azure-site-extension.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index ced47b541f..fbc97ff077 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -13,15 +13,15 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v4 - - name: Setup dotnet '6.0.x' - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '6.0.x' - - name: Display dotnet version - run: dotnet --version - - name: Display NuGet version - run: nuget ? + - uses: actions/checkout@v4 + - name: Setup dotnet '6.0.x' + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.0.x' + - name: Display dotnet version + run: dotnet --version + - name: Display NuGet version + run: nuget ? create_extension_bundle: runs-on: windows-latest From e6b6e06ceea9e50feee0864d8385926decb8b6fc Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:01:53 -0500 Subject: [PATCH 32/40] Update .github/workflows/azure-site-extension.yml Co-authored-by: James Sumners --- .github/workflows/azure-site-extension.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index fbc97ff077..531085e46f 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -4,8 +4,6 @@ on: workflow_dispatch: env: - # Enable versioned runner quiet mode to make CI output easier to read: - # OUTPUT_MODE: quiet SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec' jobs: From db67d363da60abd729c8c0a45cbbe1a3c46d3519 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:52:07 -0500 Subject: [PATCH 33/40] remove node versions --- .github/workflows/azure-site-extension.yml | 9 +++++---- .../NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 531085e46f..b79286776a 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: - node-version: ['18.x', '20.x'] # Node 22 isn't yet available for Windows apps in Azure + node-version: ['lts/*'] steps: - uses: actions/checkout@v4 @@ -44,7 +44,7 @@ jobs: - name: Set package filename run: | - echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}-${{ matrix.node-version }}" | Out-File -FilePath $env:GITHUB_ENV -Append + 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: | @@ -54,18 +54,19 @@ jobs: - name: Install agent working-directory: cloud-tooling/azure-site-extension/Content run: | - npm i --prefix Content newrelic@${{ env.AGENT_VERSION }} + 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 }}").Replace('{NODE_VERSION}', "${{ matrix.node-version }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec + (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: diff --git a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec index 0a1359b3e5..d2d5d91f08 100644 --- a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec +++ b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec @@ -2,8 +2,8 @@ NewRelic.Azure.WebSites.Extension.NodeAgent - {VERSION}-{NODE_VERSION} - New Relic Node Agent {VERSION} (Node.js {NODE_VERSION}) + {VERSION} + New Relic Node Agent {VERSION} New Relic Apache-2.0 https://github.com/newrelic/node-newrelic From 69bc4d32ed22ddfd3f4120dc48a5d4aeccd52f5c Mon Sep 17 00:00:00 2001 From: mrickard Date: Mon, 26 Aug 2024 12:13:48 -0400 Subject: [PATCH 34/40] chore: Included .NET setup in site extension bundle job Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index b79286776a..c568f8aa3b 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -7,24 +7,8 @@ env: SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec' jobs: - setup_tools: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v4 - - name: Setup dotnet '6.0.x' - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '6.0.x' - - name: Display dotnet version - run: dotnet --version - - name: Display NuGet version - run: nuget ? - create_extension_bundle: runs-on: windows-latest - needs: - - setup_tools strategy: matrix: @@ -32,6 +16,12 @@ jobs: 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: From 23d355266f264ad7016aead59a15a38835f4fa9d Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:57:31 -0500 Subject: [PATCH 35/40] update workflow to include arch and remove setting app name in readme --- .github/workflows/azure-site-extension.yml | 6 ++++-- cloud-tooling/azure-site-extension/Content/README.md | 3 +-- .../NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index c568f8aa3b..33074840e2 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -13,6 +13,7 @@ jobs: strategy: matrix: node-version: ['lts/*'] + arch: [ x86, x64 ] steps: - uses: actions/checkout@v4 @@ -26,6 +27,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: ${{ matrix.arch }} - name: Find agent version run: | @@ -34,7 +36,7 @@ jobs: - name: Set package filename run: | - echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent-${{matrix.arch}}.${{env.AGENT_VERSION}}-${{matrix.arch}}" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Verify environment vars # because we can't access GH env vars until the next step run: | @@ -50,7 +52,7 @@ jobs: - 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 + (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{ARCH}', "${{ matrix.arch }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec - name: Create bundle working-directory: cloud-tooling/azure-site-extension diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index fb4219b004..95caa49d55 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -25,10 +25,9 @@ If the extension fails to install, a log file is created at `C:\home\SiteExtensi ## 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 two configuration items before restarting your application. +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 - - `NEW_RELIC_APP_NAME` - The Node agent will automatically set the application name to the value of `WEBSITE_SITE_NAME` in azure for you application but you can override that by setting the `NEW_RELIC_APP_NAME` environment variable. 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`. diff --git a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec index d2d5d91f08..5d668fc4af 100644 --- a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec +++ b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec @@ -1,9 +1,9 @@ - NewRelic.Azure.WebSites.Extension.NodeAgent - {VERSION} - New Relic Node Agent {VERSION} + NewRelic.Azure.WebSites.Extension.NodeAgent-{ARCH} + {VERSION}-{ARCH} + New Relic Node Agent {VERSION} (Arch {ARCH}) New Relic Apache-2.0 https://github.com/newrelic/node-newrelic From 7934b6c8e85d3187b61d63c64daa9ff6838dcd4a Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:56:26 -0500 Subject: [PATCH 36/40] Remove x86 from workflow --- .github/workflows/azure-site-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 33074840e2..0d3b9d5129 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: node-version: ['lts/*'] - arch: [ x86, x64 ] + arch: [ x64 ] steps: - uses: actions/checkout@v4 From 255921677876f196376bc10c96b0c591933465c1 Mon Sep 17 00:00:00 2001 From: mrickard Date: Tue, 3 Sep 2024 17:05:03 -0400 Subject: [PATCH 37/40] chore: Edited README.md Signed-off-by: mrickard --- cloud-tooling/azure-site-extension/Content/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index 95caa49d55..eecbcc89a1 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -19,9 +19,13 @@ 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`. + + ## 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/). @@ -40,6 +44,6 @@ Below is a description of the files that make up the extension. This can be help - `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 installtion artifacts when the extension is removed - + - `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. From 77a53c0b8b95cdf49243072e85a006eb8dc407df Mon Sep 17 00:00:00 2001 From: mrickard Date: Wed, 4 Sep 2024 16:23:30 -0400 Subject: [PATCH 38/40] chore: Restored x86 build. Added compatibility note to readme. Added build-selection instruction. Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 2 +- cloud-tooling/azure-site-extension/Content/README.md | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 0d3b9d5129..33074840e2 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: node-version: ['lts/*'] - arch: [ x64 ] + arch: [ x86, x64 ] steps: - uses: actions/checkout@v4 diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index eecbcc89a1..a12e565115 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -11,7 +11,9 @@ From the Azure Home page, do the following: - 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 +- From the extension drop down, select New Relic Node Agent. + - If your application runs on Win 32, select the x86 version of the site extension. + - If your application runs on Win 64, select the x64 version of the site extension. - Check the box for accepting the legal terms - Click Add on the bottom of the page. This will begin installation of the extension. @@ -25,6 +27,9 @@ If the extension fails to install, a log file is created at `C:\home\SiteExtensi 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: + +For Node 18 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/). From 759ea11b91cddfa10d98919b91e32e44c2b9dede Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 5 Sep 2024 11:29:06 -0400 Subject: [PATCH 39/40] chore: Removed x86 build, removed architecture from nuspec, updated readme Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 6 +++--- cloud-tooling/azure-site-extension/Content/README.md | 6 ++---- .../NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index 33074840e2..d19a319d9f 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: node-version: ['lts/*'] - arch: [ x86, x64 ] + arch: [ x64 ] steps: - uses: actions/checkout@v4 @@ -36,7 +36,7 @@ jobs: - name: Set package filename run: | - echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent-${{matrix.arch}}.${{env.AGENT_VERSION}}-${{matrix.arch}}" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent-${{env.AGENT_VERSION}}-${{matrix.arch}}" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Verify environment vars # because we can't access GH env vars until the next step run: | @@ -52,7 +52,7 @@ jobs: - name: Configure package files working-directory: cloud-tooling/azure-site-extension run: | - (Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}").Replace('{ARCH}', "${{ matrix.arch }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec + (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 diff --git a/cloud-tooling/azure-site-extension/Content/README.md b/cloud-tooling/azure-site-extension/Content/README.md index a12e565115..1d0b1b4327 100644 --- a/cloud-tooling/azure-site-extension/Content/README.md +++ b/cloud-tooling/azure-site-extension/Content/README.md @@ -12,8 +12,6 @@ From the Azure Home page, do the following: - 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. - - If your application runs on Win 32, select the x86 version of the site extension. - - If your application runs on Win 64, select the x64 version of the site extension. - Check the box for accepting the legal terms - Click Add on the bottom of the page. This will begin installation of the extension. @@ -27,9 +25,9 @@ If the extension fails to install, a log file is created at `C:\home\SiteExtensi 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: +### Compatibility note: -For Node 18 on Win 32, full Code Level Metrics support (file path, line, column) is not available, and profiling will fall back to function name only. +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/). diff --git a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec index 5d668fc4af..d2d5d91f08 100644 --- a/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec +++ b/cloud-tooling/azure-site-extension/NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec @@ -1,9 +1,9 @@ - NewRelic.Azure.WebSites.Extension.NodeAgent-{ARCH} - {VERSION}-{ARCH} - New Relic Node Agent {VERSION} (Arch {ARCH}) + NewRelic.Azure.WebSites.Extension.NodeAgent + {VERSION} + New Relic Node Agent {VERSION} New Relic Apache-2.0 https://github.com/newrelic/node-newrelic From 93aae612aecd1c911446a14f5c2ac13853c6e9e0 Mon Sep 17 00:00:00 2001 From: mrickard Date: Thu, 5 Sep 2024 15:54:26 -0400 Subject: [PATCH 40/40] chore: Removed architecture notation from site extension filename Signed-off-by: mrickard --- .github/workflows/azure-site-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/azure-site-extension.yml b/.github/workflows/azure-site-extension.yml index d19a319d9f..4036e56fe3 100644 --- a/.github/workflows/azure-site-extension.yml +++ b/.github/workflows/azure-site-extension.yml @@ -36,7 +36,7 @@ jobs: - name: Set package filename run: | - echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent-${{env.AGENT_VERSION}}-${{matrix.arch}}" | Out-File -FilePath $env:GITHUB_ENV -Append + 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: |