Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Deprecate AzureRM - PowerShellContext #1394

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion source/Calamari/Kubernetes/KubernetesContextScriptWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Calamari.Common.Features.Processes;
using Calamari.Common.Features.Scripting;
using Calamari.Common.Features.Scripts;
using Calamari.Common.FeatureToggles;
using Calamari.Common.Plumbing.FileSystem;
using Calamari.Common.Plumbing.Logging;
using Calamari.Common.Plumbing.Variables;
Expand Down Expand Up @@ -81,6 +82,7 @@ public CommandResult ExecuteScript(Script script,
{
variables.Set("OctopusKubernetesTargetScript", $"{script.File}");
variables.Set("OctopusKubernetesTargetScriptParameters", script.Parameters);
variables.Set("OctopusAzureRmIsDeprecated", FeatureToggle.AzureRMDeprecationFeatureToggle.IsEnabled(variables).ToString());

using (var contextScriptFile = new TemporaryFile(CreateContextScriptFile(workingDirectory)))
{
Expand All @@ -100,4 +102,4 @@ string CreateContextScriptFile(string workingDirectory)
return contextScriptFile;
}
}
}
}
12 changes: 11 additions & 1 deletion source/Calamari/Kubernetes/Scripts/AzurePowershellContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ $OctopusAzureEnvironment = $OctopusParameters["Octopus.Action.Azure.Environment"
$OctopusOpenIdJwt = $OctopusParameters["Octopus.OpenIdConnect.Jwt"]
$OctopusUseOidc = ![string]::IsNullOrEmpty($OctopusOpenIdJwt)

## The script is passed the following parameters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version of Server are you targeting? I've made a breaking change in Calamari (#1405) so you'll need to target a 28.x.x branch if this is going to 2024.4

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'll need to be 2025.1 - so main is fine (i.e. I don't really want to push this out to on-prem).
Aside from that - the feature toggle should probably be flipped to prevent the usage of AzureRM by default (but with an escape hatch).

## $OctopusAzureRmIsDeprecated = "..."

if ($null -eq $OctopusAzureEnvironment)
{
$OctopusAzureEnvironment = "AzureCloud"
Expand Down Expand Up @@ -153,7 +156,14 @@ function ConnectAzAccount
}
elseif (Get-AzureRmModuleInstalled)
{
Initialize-AzureRmContext
if($OctopusAzureRmIsDeprecated -like [Boolean]::TrueString) {
Write-Error "Azure Resource Manager modules are no longer available for authenticating with Azure, you are required to move to Azure CLI or the Az powershell modules."
exit 2
}
else {
Write-Warning "Azure Resource Manager powershell module has reached end-of-life; please authenticate using Azure CLI or the Az module, Octopus will prevent usage of the AzureRM module in 2024.3."
Initialize-AzureRmContext
}
}
}
}
Expand Down