Skip to content

Env variable logic for AZ PS upgrade notification #1001

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ public async static Task Main(string[] args)
}
});

// This must be done before the first Runspace is created, to avoid the creation of a thread by the upgrade checker
SetVersionUpgradeOptOut();

// Create the very first Runspace so the debugger has the target to attach to.
// This PowerShell instance is shared by the first PowerShellManager instance created in the pool,
// and the dependency manager (used to download dependent modules if needed).

var firstPowerShellInstance = Utils.NewPwshInstance();
var pwshVersion = Utils.GetPowerShellVersion(firstPowerShellInstance);
LogPowerShellVersion(pwshVersion);
Expand All @@ -101,6 +105,15 @@ public async static Task Main(string[] args)
await requestProcessor.ProcessRequestLoop();
}

private static void SetVersionUpgradeOptOut()
{
string checkForUpgrade = Environment.GetEnvironmentVariable("AZUREPS_CHECK_FOR_UPGRADE");
if (string.IsNullOrWhiteSpace(checkForUpgrade))
{
Environment.SetEnvironmentVariable("AZUREPS_CHECK_FOR_UPGRADE", "False");
}
}

// Warm up the PowerShell instance so that the subsequent function load and invocation requests are faster
private static void WarmUpPowerShell(System.Management.Automation.PowerShell firstPowerShellInstance)
{
Expand Down