Skip to content

Conversation

Copy link

Copilot AI commented Jan 20, 2026

PR Azure#29067 calls Get-AzEnvironment twice in the same code path: once in the conditional check, again to access properties.

Changes

  • Store Get-AzEnvironment result in $azEnv variable before use
  • Apply to 4 functions: $registerArcScript, Get-ManagementUrl, Get-PortalDomain, Get-EnvironmentEndpoints
  • Update ChangeLog description

Example

Before:

elseif ($null -ne (Get-AzEnvironment -Name $EnvironmentName))
{
    $managementUrl = (Get-AzEnvironment -Name $EnvironmentName).ResourceManagerUrl
}

After:

else
{
    $azEnv = Get-AzEnvironment -Name $EnvironmentName
    if ($null -ne $azEnv)
    {
        $managementUrl = $azEnv.ResourceManagerUrl
    }
}

Reduces 8 calls to 4 across the affected code paths.

Original prompt

Remove the duplication of fetching azure environment again and again in the changed code in pull request Azure#29067


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: prateekprshr-nith <8659147+prateekprshr-nith@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove duplication of fetching Azure environment Eliminate redundant Get-AzEnvironment calls in custom environment support Jan 20, 2026
Co-authored-by: prateekprshr-nith <8659147+prateekprshr-nith@users.noreply.github.com>
Copilot AI changed the title Eliminate redundant Get-AzEnvironment calls in custom environment support Add custom Azure Environment support without caching overhead Jan 20, 2026
Copilot AI changed the title Add custom Azure Environment support without caching overhead Eliminate redundant Get-AzEnvironment calls in custom environment support Jan 20, 2026
Copilot AI changed the title Eliminate redundant Get-AzEnvironment calls in custom environment support Remove redundant Get-AzEnvironment calls in custom environment support Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants