From bcfb43a3b6be1408f1579e1ab1cc81c1457bffde Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Fri, 9 Aug 2024 13:48:28 -0500
Subject: [PATCH 01/21] wip extension scripts
---
.../Content/check-version.ps1 | 39 +++++++++++++++++++
.../azure-site-extension/Content/install.cmd | 9 +++++
.../azure-site-extension/Content/install.ps1 | 31 +++++++++++++++
3 files changed, 79 insertions(+)
create mode 100644 cloud-tooling/azure-site-extension/Content/check-version.ps1
create mode 100644 cloud-tooling/azure-site-extension/Content/install.cmd
create mode 100644 cloud-tooling/azure-site-extension/Content/install.ps1
diff --git a/cloud-tooling/azure-site-extension/Content/check-version.ps1 b/cloud-tooling/azure-site-extension/Content/check-version.ps1
new file mode 100644
index 0000000000..6c72be6409
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/check-version.ps1
@@ -0,0 +1,39 @@
+# Define the path to the node_modules directory and the package to check
+$UserNodeModulesPath = "D:\home\site\wwwroot"
+$packageName = "newrelic"
+
+Write-Output "Checking installed version..."
+
+# Get installed version using npm list
+$installedVersionOutput = & npm ls $packageName --prefix $UserNodeModulesPath | Select-String -Pattern "$packageName@(\S+)"
+
+if ($installedVersionOutput) {
+ $UserVersion = $installedVersionOutput.Matches.Groups[1].Value
+} else {
+ $UserVersion = ""
+}
+
+Write-Output "Installed version is: $installedVersionOutput"
+Write-Output "User version: $UserVersion"
+
+if ($UserVersion -eq "") {
+ Write-Output "User package not found. Running install.ps1..."
+ & powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
+ exit $LASTEXITCODE
+} else {
+ Write-Output "Installed version: $UserVersion"
+
+ Write-Output "Getting latest version from npm..."
+ $LatestVersion = npm show $packageName version
+
+ Write-Output "Latest version: $LatestVersion"
+
+ if ($UserVersion -ne $LatestVersion) {
+ Write-Output "Installed version ($UserVersion) does not match latest version ($LatestVersion). Running install.ps1..."
+ & powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
+ exit $LASTEXITCODE
+ } else {
+ Write-Output "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
+ exit 0
+ }
+}
\ No newline at end of file
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..0201ddd25f
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/install.cmd
@@ -0,0 +1,9 @@
+:: Copyright 2024 New Relic Corporation. All rights reserved.
+:: SPDX-License-Identifier: Apache-2.0
+
+@echo off
+REM Call the PowerShell script
+powershell.exe -ExecutionPolicy Bypass -File .\check-version.ps1
+
+REM Echo the exit code
+echo %ERRORLEVEL%
\ No newline at end of file
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..ef8e44fe65
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -0,0 +1,31 @@
+# Define paths
+$extensionModulesPath = "$PSScriptRoot\node_modules"
+$appRootPath = "D:\home\site\wwwroot"
+$userModulesPath = "$appRootPath\node_modules"
+
+# Function to copy contents from extension's node_modules to user's node_modules
+function Copy-NodeModules {
+ param (
+ [string]$sourcePath,
+ [string]$destinationPath
+ )
+
+ if (Test-Path -Path $sourcePath) {
+ Write-Output "Source path exists: $sourcePath"
+
+ if (-not (Test-Path -Path $destinationPath)) {
+ Write-Output "Destination path does not exist: $destinationPath"
+ Write-Output "Creating destination directory..."
+ New-Item -ItemType Directory -Path $destinationPath
+ }
+
+ Write-Output "Copying node_modules from $sourcePath to $destinationPath..."
+ Copy-Item -Path "$sourcePath\*" -Destination $destinationPath -Recurse -Force
+ Write-Output "Copy complete."
+ } else {
+ Write-Output "Source path does not exist: $sourcePath. Skipping copy."
+ }
+}
+
+# Call the function
+Copy-NodeModules -sourcePath $extensionModulesPath -destinationPath $userModulesPath
\ No newline at end of file
From d08187b3651616860ec45bba848037d9719eb8d6 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Fri, 9 Aug 2024 15:19:31 -0500
Subject: [PATCH 02/21] Add spec files
---
.../azure-site-extension/Content/.gitignore | 2 ++
....Azure.Websites.Extension.NodeAgent.nuspec | 24 +++++++++++++++++++
.../Content/applicationHost.xdt | 11 +++++++++
.../Content/check-version.ps1 | 2 +-
.../azure-site-extension/Content/install.cmd | 2 +-
.../azure-site-extension/Content/install.ps1 | 2 +-
.../azure-site-extension/Content/publish.sh | 12 ++++++++++
.../Content/scmApplicationHost.xdt | 5 ++++
.../Content/siteextension.json | 9 +++++++
.../Content/uninstall.cmd | 7 ++++++
10 files changed, 73 insertions(+), 3 deletions(-)
create mode 100644 cloud-tooling/azure-site-extension/Content/.gitignore
create mode 100644 cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec
create mode 100644 cloud-tooling/azure-site-extension/Content/applicationHost.xdt
create mode 100644 cloud-tooling/azure-site-extension/Content/publish.sh
create mode 100644 cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt
create mode 100644 cloud-tooling/azure-site-extension/Content/siteextension.json
create mode 100644 cloud-tooling/azure-site-extension/Content/uninstall.cmd
diff --git a/cloud-tooling/azure-site-extension/Content/.gitignore b/cloud-tooling/azure-site-extension/Content/.gitignore
new file mode 100644
index 0000000000..17966dc2f5
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/.gitignore
@@ -0,0 +1,2 @@
+NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg
+NewRelic.Azure.WebSites.Extension.NodeAgent.*.nuspec
\ No newline at end of file
diff --git a/cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec
new file mode 100644
index 0000000000..67eddcfbbe
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec
@@ -0,0 +1,24 @@
+
+
+
+ NewRelic.Azure.WebSites.Extension.NodeAgent
+ {VERSION}
+ New Relic Node Agent
+ 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
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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..295d3eb7a5
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cloud-tooling/azure-site-extension/Content/check-version.ps1 b/cloud-tooling/azure-site-extension/Content/check-version.ps1
index 6c72be6409..0567655bc2 100644
--- a/cloud-tooling/azure-site-extension/Content/check-version.ps1
+++ b/cloud-tooling/azure-site-extension/Content/check-version.ps1
@@ -36,4 +36,4 @@ if ($UserVersion -eq "") {
Write-Output "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
exit 0
}
-}
\ No newline at end of file
+}
diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd
index 0201ddd25f..d016e75a8d 100644
--- a/cloud-tooling/azure-site-extension/Content/install.cmd
+++ b/cloud-tooling/azure-site-extension/Content/install.cmd
@@ -6,4 +6,4 @@ REM Call the PowerShell script
powershell.exe -ExecutionPolicy Bypass -File .\check-version.ps1
REM Echo the exit code
-echo %ERRORLEVEL%
\ No newline at end of file
+echo %ERRORLEVEL%
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index ef8e44fe65..cf3cab973f 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -28,4 +28,4 @@ function Copy-NodeModules {
}
# Call the function
-Copy-NodeModules -sourcePath $extensionModulesPath -destinationPath $userModulesPath
\ No newline at end of file
+Copy-NodeModules -sourcePath $extensionModulesPath -destinationPath $userModulesPath
diff --git a/cloud-tooling/azure-site-extension/Content/publish.sh b/cloud-tooling/azure-site-extension/Content/publish.sh
new file mode 100644
index 0000000000..3b255b1e84
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/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 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}
\ No newline at end of file
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..a8dd367f9f
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
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..baa7a07045
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/siteextension.json
@@ -0,0 +1,9 @@
+{
+ "id": "New Relic Node Agent Extension",
+ "title": "New Relic Node Agent Extension",
+ "description": "A New Relic Node Agent site extension for Azure Web Apps.",
+ "version": "1.0.0",
+ "authors": ["New Relic"],
+ "tags": ["Node", "Azure", "Extension"],
+ "type": "WebRoot"
+}
\ No newline at end of file
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..d1d439b84c
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/uninstall.cmd
@@ -0,0 +1,7 @@
+:: Copyright 2024 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 e4e18dca0997f6276421780bf408b1b98ee016af Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Fri, 9 Aug 2024 15:22:10 -0500
Subject: [PATCH 03/21] Add version file
---
cloud-tooling/azure-site-extension/Content/version.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 cloud-tooling/azure-site-extension/Content/version.txt
diff --git a/cloud-tooling/azure-site-extension/Content/version.txt b/cloud-tooling/azure-site-extension/Content/version.txt
new file mode 100644
index 0000000000..b0d364502e
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/version.txt
@@ -0,0 +1 @@
+12.0.0
\ No newline at end of file
From 4f33dc3cc83aa03706fd99e4385b022e80ffe380 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 09:39:43 -0500
Subject: [PATCH 04/21] update install script
---
cloud-tooling/azure-site-extension/.gitignore | 1 +
.../Content/check-version.ps1 | 2 +-
.../azure-site-extension/Content/install.ps1 | 45 +++++++++++++------
3 files changed, 34 insertions(+), 14 deletions(-)
create mode 100644 cloud-tooling/azure-site-extension/.gitignore
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
diff --git a/cloud-tooling/azure-site-extension/Content/check-version.ps1 b/cloud-tooling/azure-site-extension/Content/check-version.ps1
index 0567655bc2..fdffcc2788 100644
--- a/cloud-tooling/azure-site-extension/Content/check-version.ps1
+++ b/cloud-tooling/azure-site-extension/Content/check-version.ps1
@@ -1,5 +1,5 @@
# Define the path to the node_modules directory and the package to check
-$UserNodeModulesPath = "D:\home\site\wwwroot"
+$UserNodeModulesPath = "$env:HOME"
$packageName = "newrelic"
Write-Output "Checking installed version..."
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index cf3cab973f..c5af46c750 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -1,30 +1,49 @@
# Define paths
$extensionModulesPath = "$PSScriptRoot\node_modules"
-$appRootPath = "D:\home\site\wwwroot"
+$appRootPath = "$env:HOME\site\wwwroot"
$userModulesPath = "$appRootPath\node_modules"
+function WriteToInstallLog($output)
+{
+ $logPath = (Split-Path -Parent $PSCommandPath) + "\install.log"
+ Write-Output "[$(Get-Date)] -- $output" | Out-File -FilePath $logPath -Append
+}
+
# Function to copy contents from extension's node_modules to user's node_modules
function Copy-NodeModules {
- param (
- [string]$sourcePath,
- [string]$destinationPath
- )
+ param (
+ [string]$sourcePath,
+ [string]$destinationPath
+ )
+
+ try {
+ WriteToInstallLog "Start executing install.ps1"
if (Test-Path -Path $sourcePath) {
- Write-Output "Source path exists: $sourcePath"
+ WriteToInstallLog "Source path exists: $sourcePath"
if (-not (Test-Path -Path $destinationPath)) {
- Write-Output "Destination path does not exist: $destinationPath"
- Write-Output "Creating destination directory..."
- New-Item -ItemType Directory -Path $destinationPath
+ WriteToInstallLog "Destination path does not exist: $destinationPath"
+ WriteToInstallLog "Creating destination directory..."
+ WriteToInstallLog -ItemType Directory -Path $destinationPath
}
- Write-Output "Copying node_modules from $sourcePath to $destinationPath..."
- Copy-Item -Path "$sourcePath\*" -Destination $destinationPath -Recurse -Force
- Write-Output "Copy complete."
+ WriteToInstallLog "Moving node_modules from $sourcePath to $destinationPath..."
+ Move-Item -Path "$sourcePath\*" -Destination $destinationPath -Force
+
+ WriteToInstallLog "Copy complete."
+ WriteToInstallLog "End executing install.ps1."
+ WriteToInstallLog "-----------------------------"
+ exit $LASTEXITCODE
} else {
- Write-Output "Source path does not exist: $sourcePath. Skipping copy."
+ WriteToInstallLog "Source path does not exist: $sourcePath. Skipping copy."
}
+ } catch {
+ $errorMessage = $_.Exception.Message
+ $errorLine = $_.InvocationInfo.ScriptLineNumber
+ WriteToInstallLog "Error at line $errorLine : $errorMessage"
+ exit 1
+ }
}
# Call the function
From 60d40c2a6cdf963283672fba31fa184578ecbed6 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 13:48:22 -0500
Subject: [PATCH 05/21] refactor script and add update site extension version
script
---
.../Content/applicationHost.xdt | 6 +++--
.../Content/check-version.ps1 | 25 ++++++++++++-------
.../azure-site-extension/Content/install.ps1 | 8 ++++++
.../Content/siteextension.json | 8 +++---
.../Content/update-siteextension.ps1 | 18 +++++++++++++
5 files changed, 50 insertions(+), 15 deletions(-)
create mode 100644 cloud-tooling/azure-site-extension/Content/update-siteextension.ps1
diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt
index 295d3eb7a5..2c0d228c7e 100644
--- a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt
+++ b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt
@@ -3,8 +3,10 @@
-
-
+
+
+
+
diff --git a/cloud-tooling/azure-site-extension/Content/check-version.ps1 b/cloud-tooling/azure-site-extension/Content/check-version.ps1
index fdffcc2788..f0214f0af2 100644
--- a/cloud-tooling/azure-site-extension/Content/check-version.ps1
+++ b/cloud-tooling/azure-site-extension/Content/check-version.ps1
@@ -2,7 +2,14 @@
$UserNodeModulesPath = "$env:HOME"
$packageName = "newrelic"
-Write-Output "Checking installed version..."
+function WriteToInstallLog($output)
+{
+ $logPath = (Split-Path -Parent $PSCommandPath) + "\install.log"
+ Write-Output "[$(Get-Date)] -- $output" | Out-File -FilePath $logPath -Append
+}
+
+
+WriteToInstallLog "Checking installed version..."
# Get installed version using npm list
$installedVersionOutput = & npm ls $packageName --prefix $UserNodeModulesPath | Select-String -Pattern "$packageName@(\S+)"
@@ -13,27 +20,27 @@ if ($installedVersionOutput) {
$UserVersion = ""
}
-Write-Output "Installed version is: $installedVersionOutput"
-Write-Output "User version: $UserVersion"
+WriteToInstallLog "Installed version is: $installedVersionOutput"
+WriteToInstallLog "User version: $UserVersion"
if ($UserVersion -eq "") {
- Write-Output "User package not found. Running install.ps1..."
+ WriteToInstallLog "User package not found. Running install.ps1..."
& powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
exit $LASTEXITCODE
} else {
- Write-Output "Installed version: $UserVersion"
+ WriteToInstallLog "Installed version: $UserVersion"
- Write-Output "Getting latest version from npm..."
+ WriteToInstallLog "Getting latest version from npm..."
$LatestVersion = npm show $packageName version
- Write-Output "Latest version: $LatestVersion"
+ WriteToInstallLog "Latest version: $LatestVersion"
if ($UserVersion -ne $LatestVersion) {
- Write-Output "Installed version ($UserVersion) does not match latest version ($LatestVersion). Running install.ps1..."
+ WriteToInstallLog "Installed version ($UserVersion) does not match latest version ($LatestVersion). Running install.ps1..."
& powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
exit $LASTEXITCODE
} else {
- Write-Output "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
+ WriteToInstallLog "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
exit 0
}
}
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index c5af46c750..22fb21291f 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -42,6 +42,14 @@ function Copy-NodeModules {
$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 1
}
}
diff --git a/cloud-tooling/azure-site-extension/Content/siteextension.json b/cloud-tooling/azure-site-extension/Content/siteextension.json
index baa7a07045..bbb6dfbbca 100644
--- a/cloud-tooling/azure-site-extension/Content/siteextension.json
+++ b/cloud-tooling/azure-site-extension/Content/siteextension.json
@@ -1,9 +1,9 @@
{
- "id": "New Relic Node Agent Extension",
- "title": "New Relic Node Agent Extension",
+ "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": "1.0.0",
+ "version": "12.0.0",
"authors": ["New Relic"],
"tags": ["Node", "Azure", "Extension"],
"type": "WebRoot"
-}
\ No newline at end of file
+}
diff --git a/cloud-tooling/azure-site-extension/Content/update-siteextension.ps1 b/cloud-tooling/azure-site-extension/Content/update-siteextension.ps1
new file mode 100644
index 0000000000..da4cd2ba25
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/Content/update-siteextension.ps1
@@ -0,0 +1,18 @@
+# Define paths
+$rootDir = Split-Path -Parent -Parent $PSScriptRoot
+$versionFile = Join-Path $rootDir "version.txt"
+$siteExtensionsJson = Join-Path $PSScriptRoot "siteextensions.json"
+
+# Read the version from the version.txt file
+$version = Get-Content $versionFile
+
+# Read the current siteextensions.json content
+$json = Get-Content $siteExtensionsJson -Raw | ConvertFrom-Json
+
+# Update the version field
+$json.version = $version
+
+# Write the updated content back to siteextensions.json
+$json | ConvertTo-Json -Depth 10 | Set-Content $siteExtensionsJson
+
+Write-Output "Version updated to $version in siteextensions.json"
From 47cc5227ecff776e625278cdd851693a338c030e Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 13:53:13 -0500
Subject: [PATCH 06/21] Delete
cloud-tooling/azure-site-extension/Content/.gitignore
---
cloud-tooling/azure-site-extension/Content/.gitignore | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/Content/.gitignore
diff --git a/cloud-tooling/azure-site-extension/Content/.gitignore b/cloud-tooling/azure-site-extension/Content/.gitignore
deleted file mode 100644
index 17966dc2f5..0000000000
--- a/cloud-tooling/azure-site-extension/Content/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg
-NewRelic.Azure.WebSites.Extension.NodeAgent.*.nuspec
\ No newline at end of file
From 52fb75c42cdeecfc811ac71d8ab6d2fcf4d10ccb Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 13:56:09 -0500
Subject: [PATCH 07/21] Delete
cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec
---
....Azure.Websites.Extension.NodeAgent.nuspec | 24 -------------------
1 file changed, 24 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec
diff --git a/cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec b/cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec
deleted file mode 100644
index 67eddcfbbe..0000000000
--- a/cloud-tooling/azure-site-extension/Content/NewRelic.Azure.Websites.Extension.NodeAgent.nuspec
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- NewRelic.Azure.WebSites.Extension.NodeAgent
- {VERSION}
- New Relic Node Agent
- 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
-
-
-
-
-
-
-
-
-
\ No newline at end of file
From 0a590e4581a372110814f5e33158fd0a58f965a5 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 13:57:42 -0500
Subject: [PATCH 08/21] Delete
cloud-tooling/azure-site-extension/Content/publish.sh
---
.../azure-site-extension/Content/publish.sh | 12 ------------
1 file changed, 12 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/Content/publish.sh
diff --git a/cloud-tooling/azure-site-extension/Content/publish.sh b/cloud-tooling/azure-site-extension/Content/publish.sh
deleted file mode 100644
index 3b255b1e84..0000000000
--- a/cloud-tooling/azure-site-extension/Content/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 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}
\ No newline at end of file
From c599b6c201d70d6854892d40fa7a82ab4f42c34f Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 14:27:55 -0500
Subject: [PATCH 09/21] delete site extension and version files
---
.../Content/update-siteextension.ps1 | 18 ------------------
.../azure-site-extension/Content/version.txt | 1 -
2 files changed, 19 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/Content/update-siteextension.ps1
delete mode 100644 cloud-tooling/azure-site-extension/Content/version.txt
diff --git a/cloud-tooling/azure-site-extension/Content/update-siteextension.ps1 b/cloud-tooling/azure-site-extension/Content/update-siteextension.ps1
deleted file mode 100644
index da4cd2ba25..0000000000
--- a/cloud-tooling/azure-site-extension/Content/update-siteextension.ps1
+++ /dev/null
@@ -1,18 +0,0 @@
-# Define paths
-$rootDir = Split-Path -Parent -Parent $PSScriptRoot
-$versionFile = Join-Path $rootDir "version.txt"
-$siteExtensionsJson = Join-Path $PSScriptRoot "siteextensions.json"
-
-# Read the version from the version.txt file
-$version = Get-Content $versionFile
-
-# Read the current siteextensions.json content
-$json = Get-Content $siteExtensionsJson -Raw | ConvertFrom-Json
-
-# Update the version field
-$json.version = $version
-
-# Write the updated content back to siteextensions.json
-$json | ConvertTo-Json -Depth 10 | Set-Content $siteExtensionsJson
-
-Write-Output "Version updated to $version in siteextensions.json"
diff --git a/cloud-tooling/azure-site-extension/Content/version.txt b/cloud-tooling/azure-site-extension/Content/version.txt
deleted file mode 100644
index b0d364502e..0000000000
--- a/cloud-tooling/azure-site-extension/Content/version.txt
+++ /dev/null
@@ -1 +0,0 @@
-12.0.0
\ No newline at end of file
From 247af7c123197416963f5dd008ab913a08eca9da Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 14:41:41 -0500
Subject: [PATCH 10/21] Remove application host files
---
.../Content/applicationHost.xdt | 13 -------------
.../Content/scmApplicationHost.xdt | 5 -----
2 files changed, 18 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/Content/applicationHost.xdt
delete mode 100644 cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt
diff --git a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt b/cloud-tooling/azure-site-extension/Content/applicationHost.xdt
deleted file mode 100644
index 2c0d228c7e..0000000000
--- a/cloud-tooling/azure-site-extension/Content/applicationHost.xdt
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt b/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt
deleted file mode 100644
index a8dd367f9f..0000000000
--- a/cloud-tooling/azure-site-extension/Content/scmApplicationHost.xdt
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
\ No newline at end of file
From 0a6d4999581d6be66afcebcd045a04dcfe37971d Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 14:48:46 -0500
Subject: [PATCH 11/21] delete gitignore and site extension file
---
cloud-tooling/azure-site-extension/.gitignore | 1 -
.../azure-site-extension/Content/siteextension.json | 9 ---------
2 files changed, 10 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/.gitignore
delete mode 100644 cloud-tooling/azure-site-extension/Content/siteextension.json
diff --git a/cloud-tooling/azure-site-extension/.gitignore b/cloud-tooling/azure-site-extension/.gitignore
deleted file mode 100644
index 5bdf479bc9..0000000000
--- a/cloud-tooling/azure-site-extension/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-NewRelic.Azure.WebSites.Extension.NodeAgent.*.nupkg
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 9205318c0161b4a5a907f92f723172714bfb708f Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Mon, 19 Aug 2024 14:51:34 -0500
Subject: [PATCH 12/21] fix lint
---
.../Content/check-version.ps1 | 38 +++++++++----------
.../azure-site-extension/Content/install.ps1 | 30 +++++++--------
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/cloud-tooling/azure-site-extension/Content/check-version.ps1 b/cloud-tooling/azure-site-extension/Content/check-version.ps1
index f0214f0af2..0bad2ac24b 100644
--- a/cloud-tooling/azure-site-extension/Content/check-version.ps1
+++ b/cloud-tooling/azure-site-extension/Content/check-version.ps1
@@ -15,32 +15,32 @@ WriteToInstallLog "Checking installed version..."
$installedVersionOutput = & npm ls $packageName --prefix $UserNodeModulesPath | Select-String -Pattern "$packageName@(\S+)"
if ($installedVersionOutput) {
- $UserVersion = $installedVersionOutput.Matches.Groups[1].Value
+ $UserVersion = $installedVersionOutput.Matches.Groups[1].Value
} else {
- $UserVersion = ""
+ $UserVersion = ""
}
WriteToInstallLog "Installed version is: $installedVersionOutput"
WriteToInstallLog "User version: $UserVersion"
if ($UserVersion -eq "") {
- WriteToInstallLog "User package not found. Running install.ps1..."
+ WriteToInstallLog "User package not found. Running install.ps1..."
+ & powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
+ exit $LASTEXITCODE
+} else {
+ WriteToInstallLog "Installed version: $UserVersion"
+
+ WriteToInstallLog "Getting latest version from npm..."
+ $LatestVersion = npm show $packageName version
+
+ WriteToInstallLog "Latest version: $LatestVersion"
+
+ if ($UserVersion -ne $LatestVersion) {
+ WriteToInstallLog "Installed version ($UserVersion) does not match latest version ($LatestVersion). Running install.ps1..."
& powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
exit $LASTEXITCODE
-} else {
- WriteToInstallLog "Installed version: $UserVersion"
-
- WriteToInstallLog "Getting latest version from npm..."
- $LatestVersion = npm show $packageName version
-
- WriteToInstallLog "Latest version: $LatestVersion"
-
- if ($UserVersion -ne $LatestVersion) {
- WriteToInstallLog "Installed version ($UserVersion) does not match latest version ($LatestVersion). Running install.ps1..."
- & powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
- exit $LASTEXITCODE
- } else {
- WriteToInstallLog "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
- exit 0
- }
+ } else {
+ WriteToInstallLog "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
+ exit 0
+ }
}
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index 22fb21291f..8a61f4a4a0 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -9,7 +9,7 @@ function WriteToInstallLog($output)
Write-Output "[$(Get-Date)] -- $output" | Out-File -FilePath $logPath -Append
}
-# Function to copy contents from extension's node_modules to user's node_modules
+# Function to move contents from extension's node_modules to user's node_modules
function Copy-NodeModules {
param (
[string]$sourcePath,
@@ -21,20 +21,20 @@ function Copy-NodeModules {
if (Test-Path -Path $sourcePath) {
WriteToInstallLog "Source path exists: $sourcePath"
-
- if (-not (Test-Path -Path $destinationPath)) {
- WriteToInstallLog "Destination path does not exist: $destinationPath"
- WriteToInstallLog "Creating destination directory..."
- WriteToInstallLog -ItemType Directory -Path $destinationPath
- }
-
- WriteToInstallLog "Moving node_modules from $sourcePath to $destinationPath..."
- Move-Item -Path "$sourcePath\*" -Destination $destinationPath -Force
-
- WriteToInstallLog "Copy complete."
- WriteToInstallLog "End executing install.ps1."
- WriteToInstallLog "-----------------------------"
- exit $LASTEXITCODE
+
+ if (-not (Test-Path -Path $destinationPath)) {
+ WriteToInstallLog "Destination path does not exist: $destinationPath"
+ WriteToInstallLog "Creating destination directory..."
+ WriteToInstallLog -ItemType Directory -Path $destinationPath
+ }
+
+ WriteToInstallLog "Moving node_modules from $sourcePath to $destinationPath..."
+ Move-Item -Path "$sourcePath\*" -Destination $destinationPath -Force
+
+ WriteToInstallLog "Copy complete."
+ WriteToInstallLog "End executing install.ps1."
+ WriteToInstallLog "-----------------------------"
+ exit $LASTEXITCODE
} else {
WriteToInstallLog "Source path does not exist: $sourcePath. Skipping copy."
}
From 0db8d2f86c81bcaf5a37291f9a822506db15d665 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Wed, 21 Aug 2024 13:51:56 -0500
Subject: [PATCH 13/21] refactor install scripts
---
.../Content/check-version.ps1 | 46 ------------------
.../azure-site-extension/Content/install.cmd | 2 +-
.../azure-site-extension/Content/install.ps1 | 47 ++++++++++++++++++-
3 files changed, 46 insertions(+), 49 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/Content/check-version.ps1
diff --git a/cloud-tooling/azure-site-extension/Content/check-version.ps1 b/cloud-tooling/azure-site-extension/Content/check-version.ps1
deleted file mode 100644
index 0bad2ac24b..0000000000
--- a/cloud-tooling/azure-site-extension/Content/check-version.ps1
+++ /dev/null
@@ -1,46 +0,0 @@
-# Define the path to the node_modules directory and the package to check
-$UserNodeModulesPath = "$env:HOME"
-$packageName = "newrelic"
-
-function WriteToInstallLog($output)
-{
- $logPath = (Split-Path -Parent $PSCommandPath) + "\install.log"
- Write-Output "[$(Get-Date)] -- $output" | Out-File -FilePath $logPath -Append
-}
-
-
-WriteToInstallLog "Checking installed version..."
-
-# Get installed version using npm list
-$installedVersionOutput = & npm ls $packageName --prefix $UserNodeModulesPath | Select-String -Pattern "$packageName@(\S+)"
-
-if ($installedVersionOutput) {
- $UserVersion = $installedVersionOutput.Matches.Groups[1].Value
-} else {
- $UserVersion = ""
-}
-
-WriteToInstallLog "Installed version is: $installedVersionOutput"
-WriteToInstallLog "User version: $UserVersion"
-
-if ($UserVersion -eq "") {
- WriteToInstallLog "User package not found. Running install.ps1..."
- & powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
- exit $LASTEXITCODE
-} else {
- WriteToInstallLog "Installed version: $UserVersion"
-
- WriteToInstallLog "Getting latest version from npm..."
- $LatestVersion = npm show $packageName version
-
- WriteToInstallLog "Latest version: $LatestVersion"
-
- if ($UserVersion -ne $LatestVersion) {
- WriteToInstallLog "Installed version ($UserVersion) does not match latest version ($LatestVersion). Running install.ps1..."
- & powershell.exe -ExecutionPolicy RemoteSigned -File .\install.ps1
- exit $LASTEXITCODE
- } else {
- WriteToInstallLog "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
- exit 0
- }
-}
diff --git a/cloud-tooling/azure-site-extension/Content/install.cmd b/cloud-tooling/azure-site-extension/Content/install.cmd
index d016e75a8d..bdca190568 100644
--- a/cloud-tooling/azure-site-extension/Content/install.cmd
+++ b/cloud-tooling/azure-site-extension/Content/install.cmd
@@ -3,7 +3,7 @@
@echo off
REM Call the PowerShell script
-powershell.exe -ExecutionPolicy Bypass -File .\check-version.ps1
+powershell.exe -ExecutionPolicy Bypass -File .\install.ps1
REM Echo the exit code
echo %ERRORLEVEL%
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index 8a61f4a4a0..25f83b85a8 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -3,12 +3,55 @@ $extensionModulesPath = "$PSScriptRoot\node_modules"
$appRootPath = "$env:HOME\site\wwwroot"
$userModulesPath = "$appRootPath\node_modules"
+# Define the path to the node_modules directory and the package to check
+$UserNodeModulesPath = "$env:HOME"
+$packageName = "newrelic"
+
function WriteToInstallLog($output)
{
$logPath = (Split-Path -Parent $PSCommandPath) + "\install.log"
Write-Output "[$(Get-Date)] -- $output" | Out-File -FilePath $logPath -Append
}
+function Check-Version {
+ WriteToInstallLog "Checking installed version..."
+
+ # Get installed version using npm list
+ $installedVersionOutput = & npm ls $packageName --prefix $UserNodeModulesPath | Select-String -Pattern "$packageName@(\S+)"
+
+ if ($installedVersionOutput) {
+ $UserVersion = $installedVersionOutput.Matches.Groups[1].Value
+ } else {
+ $UserVersion = ""
+ }
+
+ WriteToInstallLog "Installed version is: $installedVersionOutput"
+ WriteToInstallLog "User version: $UserVersion"
+
+ # Check if user package exists
+ if ($UserVersion -eq "") {
+ WriteToInstallLog "User package not found. Running install.ps1..."
+ Copy-NodeModules -sourcePath $extensionModulesPath -destinationPath $userModulesPath
+ exit $LASTEXITCODE
+ } else {
+ WriteToInstallLog "Installed version: $UserVersion"
+ WriteToInstallLog "Getting latest version from npm..."
+
+ $LatestVersion = npm show $packageName version
+ WriteToInstallLog "Latest version: $LatestVersion"
+
+ # Check if user package version matches the latest version
+ if ($UserVersion -ne $LatestVersion) {
+ WriteToInstallLog "Installed version ($UserVersion) does not match latest version ($LatestVersion). Running install.ps1..."
+ Copy-NodeModules -sourcePath $extensionModulesPath -destinationPath $userModulesPath
+ exit $LASTEXITCODE
+ } else {
+ WriteToInstallLog "Installed version ($UserVersion) matches the latest version ($LatestVersion). Skipping install.ps1..."
+ exit 0
+ }
+ }
+}
+
# Function to move contents from extension's node_modules to user's node_modules
function Copy-NodeModules {
param (
@@ -44,7 +87,7 @@ function Copy-NodeModules {
WriteToInstallLog "Error at line $errorLine : $errorMessage"
WriteToInstallLog "Explicitly adding node to path"
- SET PATH=C:\Program Files\Nodejs;%PATH%
+ $env:PATH = "C:\Program Files\Nodejs;" + $env:PATH
WriteToInstallLog "Executing npm install newrelic@latest"
npm install newrelic@latest
@@ -55,4 +98,4 @@ function Copy-NodeModules {
}
# Call the function
-Copy-NodeModules -sourcePath $extensionModulesPath -destinationPath $userModulesPath
+Check-Version
From 8af6880c940cd26dec7b62d3548228b1d4680c88 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Wed, 21 Aug 2024 16:13:15 -0500
Subject: [PATCH 14/21] Add comments to install file
---
cloud-tooling/azure-site-extension/Content/install.ps1 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index 25f83b85a8..a2222a78ce 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -62,15 +62,18 @@ function Copy-NodeModules {
try {
WriteToInstallLog "Start executing install.ps1"
+ # Check if extension's node_module directory exists
if (Test-Path -Path $sourcePath) {
WriteToInstallLog "Source path exists: $sourcePath"
+ # Check if user's node_modules directory exists and create if it doesn't
if (-not (Test-Path -Path $destinationPath)) {
WriteToInstallLog "Destination path does not exist: $destinationPath"
WriteToInstallLog "Creating destination directory..."
WriteToInstallLog -ItemType Directory -Path $destinationPath
}
+ # Move node_modules from extension's node_modules directory to users
WriteToInstallLog "Moving node_modules from $sourcePath to $destinationPath..."
Move-Item -Path "$sourcePath\*" -Destination $destinationPath -Force
@@ -86,6 +89,7 @@ function Copy-NodeModules {
$errorLine = $_.InvocationInfo.ScriptLineNumber
WriteToInstallLog "Error at line $errorLine : $errorMessage"
+ # Install node agent using npm
WriteToInstallLog "Explicitly adding node to path"
$env:PATH = "C:\Program Files\Nodejs;" + $env:PATH
WriteToInstallLog "Executing npm install newrelic@latest"
From 4e7b7db0357d9c2289b9cb429f75891cf051b323 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Thu, 22 Aug 2024 13:02:08 -0500
Subject: [PATCH 15/21] update npm install in catch block
---
.../azure-site-extension/Content/install.ps1 | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index a2222a78ce..e3772fadc4 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -7,6 +7,9 @@ $userModulesPath = "$appRootPath\node_modules"
$UserNodeModulesPath = "$env:HOME"
$packageName = "newrelic"
+WriteToInstallLog "Explicitly adding node to path"
+$env:PATH = "C:\Program Files\Nodejs;" + $env:PATH
+
function WriteToInstallLog($output)
{
$logPath = (Split-Path -Parent $PSCommandPath) + "\install.log"
@@ -90,10 +93,15 @@ function Copy-NodeModules {
WriteToInstallLog "Error at line $errorLine : $errorMessage"
# Install node agent using npm
- WriteToInstallLog "Explicitly adding node to path"
- $env:PATH = "C:\Program Files\Nodejs;" + $env:PATH
WriteToInstallLog "Executing npm install newrelic@latest"
- npm install newrelic@latest
+ npm install --prefix "$env:HOME\site\wwwroot" newrelic
+
+ # Check if the installation was successful
+ if ($LASTEXITCODE -ne 0) {
+ WriteToInstallLog "npm install failed with exit code $LASTEXITCODE"
+ } else {
+ WriteToInstallLog "npm install completed successfully"
+ }
WriteToInstallLog "End executing install.ps1."
WriteToInstallLog "-----------------------------"
From 6528e56e7b61f836c61cd6db2665101229b13623 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Thu, 22 Aug 2024 14:01:35 -0500
Subject: [PATCH 16/21] Add readme to cloud tooling directory
---
cloud-tooling/README.md | 54 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 cloud-tooling/README.md
diff --git a/cloud-tooling/README.md b/cloud-tooling/README.md
new file mode 100644
index 0000000000..569c713f5c
--- /dev/null
+++ b/cloud-tooling/README.md
@@ -0,0 +1,54 @@
+# Node Agent Cloud Tooling
+
+This repository contains various cloud based tools for the New Relic Node Agent (e.g. Azure Site Extensions).
+
+## Getting Started
+Please refer to the README of any of the cloud based tools:
+
+- [Azure Site Extensions](./azure-site-extension/README.md)
+
+## Support
+
+Should you need assistance with New Relic products, you are in good hands with several support channels.
+
+If the issue has been confirmed as a bug or is a feature request, please file a GitHub issue.
+
+**Support Channels**
+
+* [New Relic Documentation](https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/introduction-new-relic-nodejs): Comprehensive guidance for using our platform
+* [New Relic Community](https://forum.newrelic.com/): The best place to engage in troubleshooting questions
+* [New Relic Developer](https://developer.newrelic.com/): Resources for building a custom observability applications
+* [New Relic University](https://learn.newrelic.com/): A range of online training for New Relic users of every level
+* [New Relic Technical Support](https://support.newrelic.com/) 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan).
+
+
+## Privacy
+At New Relic we take your privacy and the security of your information seriously, and are committed to protecting your information. We must emphasize the importance of not sharing personal data in public forums, and ask all users to scrub logs and diagnostic information for sensitive information, whether personal, proprietary, or otherwise.
+
+We define “Personal Data” as any information relating to an identified or identifiable individual, including, for example, your name, phone number, post code or zip code, Device ID, IP address and email address.
+
+Please review [New Relic’s General Data Privacy Notice](https://newrelic.com/termsandconditions/privacy) for more information.
+
+## Contribute
+
+We encourage your contributions to improve the Node.js agent! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
+
+If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
+
+**A note about vulnerabilities**
+
+As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
+
+If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [our bug bounty program](https://docs.newrelic.com/docs/security/security-privacy/information-security/report-security-vulnerabilities/).
+
+If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
+
+To [all contributors](https://github.com/newrelic/node-newrelic/graphs/contributors), we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to [New Relic Node Agent](https://opensource.newrelic.com/projects/newrelic/node-newrelic).
+
+## License
+
+Except as noted below, the Node.js agent is licensed under the [Apache 2.0](https://apache.org/licenses/LICENSE-2.0.txt) License.
+
+The New Relic [security agent](https://github.com/newrelic/csec-node-agent) is licensed under the New Relic Software License v1.0. The New Relic security agent module may be integrated like the New Relic Node.js agent.
+
+The Node.js agent also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in [the third-party notices document](https://github.com/newrelic/node-newrelic/blob/main/THIRD_PARTY_NOTICES.md).
From 899ffcc931bc52370c393f316d65c646e2cdca32 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Thu, 22 Aug 2024 15:00:21 -0500
Subject: [PATCH 17/21] Update cloud-tooling/README.md
Co-authored-by: James Sumners
---
cloud-tooling/README.md | 45 -----------------------------------------
1 file changed, 45 deletions(-)
diff --git a/cloud-tooling/README.md b/cloud-tooling/README.md
index 569c713f5c..c406d05dee 100644
--- a/cloud-tooling/README.md
+++ b/cloud-tooling/README.md
@@ -7,48 +7,3 @@ Please refer to the README of any of the cloud based tools:
- [Azure Site Extensions](./azure-site-extension/README.md)
-## Support
-
-Should you need assistance with New Relic products, you are in good hands with several support channels.
-
-If the issue has been confirmed as a bug or is a feature request, please file a GitHub issue.
-
-**Support Channels**
-
-* [New Relic Documentation](https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/introduction-new-relic-nodejs): Comprehensive guidance for using our platform
-* [New Relic Community](https://forum.newrelic.com/): The best place to engage in troubleshooting questions
-* [New Relic Developer](https://developer.newrelic.com/): Resources for building a custom observability applications
-* [New Relic University](https://learn.newrelic.com/): A range of online training for New Relic users of every level
-* [New Relic Technical Support](https://support.newrelic.com/) 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan).
-
-
-## Privacy
-At New Relic we take your privacy and the security of your information seriously, and are committed to protecting your information. We must emphasize the importance of not sharing personal data in public forums, and ask all users to scrub logs and diagnostic information for sensitive information, whether personal, proprietary, or otherwise.
-
-We define “Personal Data” as any information relating to an identified or identifiable individual, including, for example, your name, phone number, post code or zip code, Device ID, IP address and email address.
-
-Please review [New Relic’s General Data Privacy Notice](https://newrelic.com/termsandconditions/privacy) for more information.
-
-## Contribute
-
-We encourage your contributions to improve the Node.js agent! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
-
-If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
-
-**A note about vulnerabilities**
-
-As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
-
-If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [our bug bounty program](https://docs.newrelic.com/docs/security/security-privacy/information-security/report-security-vulnerabilities/).
-
-If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
-
-To [all contributors](https://github.com/newrelic/node-newrelic/graphs/contributors), we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to [New Relic Node Agent](https://opensource.newrelic.com/projects/newrelic/node-newrelic).
-
-## License
-
-Except as noted below, the Node.js agent is licensed under the [Apache 2.0](https://apache.org/licenses/LICENSE-2.0.txt) License.
-
-The New Relic [security agent](https://github.com/newrelic/csec-node-agent) is licensed under the New Relic Software License v1.0. The New Relic security agent module may be integrated like the New Relic Node.js agent.
-
-The Node.js agent also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in [the third-party notices document](https://github.com/newrelic/node-newrelic/blob/main/THIRD_PARTY_NOTICES.md).
From 4fbb5ddc224a001c25d64f185c4c5b063a8d455a Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Fri, 23 Aug 2024 16:12:54 -0500
Subject: [PATCH 18/21] Add testing to readme
---
cloud-tooling/azure-site-extension/README.md | 105 +++++++++++++++++++
1 file changed, 105 insertions(+)
create mode 100644 cloud-tooling/azure-site-extension/README.md
diff --git a/cloud-tooling/azure-site-extension/README.md b/cloud-tooling/azure-site-extension/README.md
new file mode 100644
index 0000000000..0c03bca14f
--- /dev/null
+++ b/cloud-tooling/azure-site-extension/README.md
@@ -0,0 +1,105 @@
+## Testing
+
+How to test the site extension in Azure.
+
+1. Create web app in Azure.
+ - Home > Create a resource > Web App > Create
+ - Select the "Node Team Sandbox" subscription.
+ - Select or create a new resource group.
+ - Name your application. Uncheck "unique default hostname".
+ - Select how you want to publish your web app (code, container or static web app).
+ - Select a runtime stack.
+ - Select "Windows" as the operating system.
+ - Leave pricing on the "Free F1" option.
+ - Leave zone redundancy to "disabled".
+ - Review + create > Create. (No need to setup other things like database, deployment, networking...etc)
+
+2. Deploy web app
+ - Deploy your web application to Azure. There are several ways you can do that: manual (uploading a zip file containing your application files), Azure CLI, VS Code Extensions, local git, ftp/ftps and github actions.
+ - Make sure your deployed app has a `web.config` file that looks something like this otherwise you will get a "You do not have permission to view this directory or page" error:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Note: update the path in the web.config file to match your entry file.
+
+
+3. Install site extension
+ - You can do this in two different ways:
+ - Using CLI: Development Tools > Extensions > Add > Search for site extension
+ - Using Kudu: Development Tools > Advanced Tools > Go > Site Extensions > Gallery + Search for site extension
+4. Add environment variables
+ - Select Web App > Settings > Environment variables
+ - Add `NEW_RELIC_LICENSE_KEY`, `NEW_RELIC_LOG_ENABLED` set to `true` and `NEW_RELIC_LOG_LEVEL` set to `trace`.
+ - Click "Apply"
+5. Restart application
+ - Overview > Restart
+
+### Using Kudu to view:
+ - Site extension logs:
+ - Development Tools > Advanced Tools > Go > Debug console > Powershell > SiteExtensions > Select the site extension > install.log (download the file or click on pencil icon to see it in the console)
+ - New Relic logs:
+ - Development Tools > Advanced Tools > Go > Debug console > Powershell > site > wwwroot > newrelic_agent.log (download the file or click on pencil icon to see it in the console)
+ - Environment variables, app settings, system info, connection strings, path, headers, server variables
+ - Development Tools > Advanced Tools > Go > Environment
+ - Additional log files:
+ - Development Tools > Advanced Tools > Go > Debug console > Powershell > LogFiles
\ No newline at end of file
From f5e1b0cacea501bc022d3241e8becc8809643b0a Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Fri, 23 Aug 2024 16:15:21 -0500
Subject: [PATCH 19/21] Add another step to testing
---
cloud-tooling/azure-site-extension/README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/cloud-tooling/azure-site-extension/README.md b/cloud-tooling/azure-site-extension/README.md
index 0c03bca14f..7fda9a65b1 100644
--- a/cloud-tooling/azure-site-extension/README.md
+++ b/cloud-tooling/azure-site-extension/README.md
@@ -94,6 +94,8 @@ How to test the site extension in Azure.
5. Restart application
- Overview > Restart
+6. Send traffic to your application. You should see a `newrelic_agent.log` created in the `/site/wwwroot` directory and data should be flowing to your NR1 account.
+
### Using Kudu to view:
- Site extension logs:
- Development Tools > Advanced Tools > Go > Debug console > Powershell > SiteExtensions > Select the site extension > install.log (download the file or click on pencil icon to see it in the console)
From b69583c551a40528740029025597da4d06f59c28 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Fri, 30 Aug 2024 13:50:45 -0500
Subject: [PATCH 20/21] remove testing readme, update uninstall and refactor
env vars in install script
---
.../azure-site-extension/Content/install.ps1 | 9 +-
.../Content/uninstall.cmd | 15 ++-
cloud-tooling/azure-site-extension/README.md | 107 ------------------
3 files changed, 16 insertions(+), 115 deletions(-)
delete mode 100644 cloud-tooling/azure-site-extension/README.md
diff --git a/cloud-tooling/azure-site-extension/Content/install.ps1 b/cloud-tooling/azure-site-extension/Content/install.ps1
index e3772fadc4..47641c602e 100644
--- a/cloud-tooling/azure-site-extension/Content/install.ps1
+++ b/cloud-tooling/azure-site-extension/Content/install.ps1
@@ -1,10 +1,7 @@
-# Define paths
+# Define the path to the node_modules directory and the package to check
$extensionModulesPath = "$PSScriptRoot\node_modules"
$appRootPath = "$env:HOME\site\wwwroot"
$userModulesPath = "$appRootPath\node_modules"
-
-# Define the path to the node_modules directory and the package to check
-$UserNodeModulesPath = "$env:HOME"
$packageName = "newrelic"
WriteToInstallLog "Explicitly adding node to path"
@@ -20,7 +17,7 @@ function Check-Version {
WriteToInstallLog "Checking installed version..."
# Get installed version using npm list
- $installedVersionOutput = & npm ls $packageName --prefix $UserNodeModulesPath | Select-String -Pattern "$packageName@(\S+)"
+ $installedVersionOutput = & npm ls $packageName --prefix "$env:HOME" | Select-String -Pattern "$packageName@(\S+)"
if ($installedVersionOutput) {
$UserVersion = $installedVersionOutput.Matches.Groups[1].Value
@@ -94,7 +91,7 @@ function Copy-NodeModules {
# Install node agent using npm
WriteToInstallLog "Executing npm install newrelic@latest"
- npm install --prefix "$env:HOME\site\wwwroot" newrelic
+ npm install --prefix $appRootPath newrelic
# Check if the installation was successful
if ($LASTEXITCODE -ne 0) {
diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd
index d1d439b84c..f4f7cdc910 100644
--- a/cloud-tooling/azure-site-extension/Content/uninstall.cmd
+++ b/cloud-tooling/azure-site-extension/Content/uninstall.cmd
@@ -1,7 +1,18 @@
:: Copyright 2024 New Relic Corporation. All rights reserved.
:: SPDX-License-Identifier: Apache-2.0
-SET NEW_RELIC_FOLDER="%HOME%\node_modules/newrelic"
+SET NEW_RELIC_FOLDER="%HOME%\site\wwwroot\node_modules\newrelic"
IF EXIST %NEW_RELIC_FOLDER% (
- npm uninstall newrelic
+ echo Uninstalling newrelic...
+ cd "%HOME%\site\wwwroot"
+ call npm uninstall newrelic --save
+ rmdir /s /q "%HOME%\site\wwwroot\node_modules\@newrelic"
+ IF %ERRORLEVEL% NEQ 0 (
+ echo Failed to uninstall newrelic
+ exit /b 1
+ ) ELSE (
+ echo Successfully uninstalled newrelic
+ )
+) ELSE (
+ echo newrelic package not found in node_modules
)
diff --git a/cloud-tooling/azure-site-extension/README.md b/cloud-tooling/azure-site-extension/README.md
deleted file mode 100644
index 7fda9a65b1..0000000000
--- a/cloud-tooling/azure-site-extension/README.md
+++ /dev/null
@@ -1,107 +0,0 @@
-## Testing
-
-How to test the site extension in Azure.
-
-1. Create web app in Azure.
- - Home > Create a resource > Web App > Create
- - Select the "Node Team Sandbox" subscription.
- - Select or create a new resource group.
- - Name your application. Uncheck "unique default hostname".
- - Select how you want to publish your web app (code, container or static web app).
- - Select a runtime stack.
- - Select "Windows" as the operating system.
- - Leave pricing on the "Free F1" option.
- - Leave zone redundancy to "disabled".
- - Review + create > Create. (No need to setup other things like database, deployment, networking...etc)
-
-2. Deploy web app
- - Deploy your web application to Azure. There are several ways you can do that: manual (uploading a zip file containing your application files), Azure CLI, VS Code Extensions, local git, ftp/ftps and github actions.
- - Make sure your deployed app has a `web.config` file that looks something like this otherwise you will get a "You do not have permission to view this directory or page" error:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Note: update the path in the web.config file to match your entry file.
-
-
-3. Install site extension
- - You can do this in two different ways:
- - Using CLI: Development Tools > Extensions > Add > Search for site extension
- - Using Kudu: Development Tools > Advanced Tools > Go > Site Extensions > Gallery + Search for site extension
-4. Add environment variables
- - Select Web App > Settings > Environment variables
- - Add `NEW_RELIC_LICENSE_KEY`, `NEW_RELIC_LOG_ENABLED` set to `true` and `NEW_RELIC_LOG_LEVEL` set to `trace`.
- - Click "Apply"
-5. Restart application
- - Overview > Restart
-
-6. Send traffic to your application. You should see a `newrelic_agent.log` created in the `/site/wwwroot` directory and data should be flowing to your NR1 account.
-
-### Using Kudu to view:
- - Site extension logs:
- - Development Tools > Advanced Tools > Go > Debug console > Powershell > SiteExtensions > Select the site extension > install.log (download the file or click on pencil icon to see it in the console)
- - New Relic logs:
- - Development Tools > Advanced Tools > Go > Debug console > Powershell > site > wwwroot > newrelic_agent.log (download the file or click on pencil icon to see it in the console)
- - Environment variables, app settings, system info, connection strings, path, headers, server variables
- - Development Tools > Advanced Tools > Go > Environment
- - Additional log files:
- - Development Tools > Advanced Tools > Go > Debug console > Powershell > LogFiles
\ No newline at end of file
From 0286e8af6490c34b7b495fb490fc3f5da515f098 Mon Sep 17 00:00:00 2001
From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com>
Date: Tue, 3 Sep 2024 12:51:16 -0500
Subject: [PATCH 21/21] Update uninstall script to remove empty @ directories
---
.../Content/uninstall.cmd | 32 ++++++++++++++++---
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/cloud-tooling/azure-site-extension/Content/uninstall.cmd b/cloud-tooling/azure-site-extension/Content/uninstall.cmd
index f4f7cdc910..3e6f2a7a86 100644
--- a/cloud-tooling/azure-site-extension/Content/uninstall.cmd
+++ b/cloud-tooling/azure-site-extension/Content/uninstall.cmd
@@ -1,13 +1,19 @@
:: Copyright 2024 New Relic Corporation. All rights reserved.
:: SPDX-License-Identifier: Apache-2.0
-SET NEW_RELIC_FOLDER="%HOME%\site\wwwroot\node_modules\newrelic"
+@echo off
+setlocal enabledelayedexpansion
+
+SET ROOT_DIR=%HOME%\site\wwwroot
+SET NODE_MODULES=%ROOT_DIR%\node_modules
+
+REM Uninstall newrelic if it exists
+SET NEW_RELIC_FOLDER="%NODE_MODULES%\newrelic"
IF EXIST %NEW_RELIC_FOLDER% (
echo Uninstalling newrelic...
- cd "%HOME%\site\wwwroot"
+ cd "%ROOT_DIR%"
call npm uninstall newrelic --save
- rmdir /s /q "%HOME%\site\wwwroot\node_modules\@newrelic"
- IF %ERRORLEVEL% NEQ 0 (
+ IF !ERRORLEVEL! NEQ 0 (
echo Failed to uninstall newrelic
exit /b 1
) ELSE (
@@ -16,3 +22,21 @@ IF EXIST %NEW_RELIC_FOLDER% (
) ELSE (
echo newrelic package not found in node_modules
)
+
+REM Loop through directories starting with @ in node_modules
+FOR /D %%G IN ("%NODE_MODULES%\@*") DO (
+ SET "DIR_EMPTY=1"
+ FOR /F %%A IN ('dir /a /b "%%G" 2^>nul') DO SET "DIR_EMPTY=0"
+ IF !DIR_EMPTY!==1 (
+ echo Removing empty directory: %%G
+ rmdir /s /q "%%G"
+ IF !ERRORLEVEL! NEQ 0 (
+ echo Failed to remove directory: %%G
+ exit /b 1
+ )
+ )
+)
+
+echo Script completed successfully
+endlocal
+exit /b 0