azure-functions-powershell-worker
azure-functions-powershell-worker copied to clipboard
Update profile.ps1 to include the Environment (if available) in Connect-AzAccount
This change will be required in all Functions' clients.
This is the current template:
# Authenticate with Azure PowerShell using MSI.
# Remove this if you are not planning on using MSI or Azure PowerShell.
if ($env:MSI_SECRET -and (Get-Module -ListAvailable Az.Accounts)) {
Disable-AzContextAutosave -Scope Process | Out-Null
Connect-AzAccount -Identity
}
Propose change:
# Authenticate with Azure PowerShell using MSI.
# Remove this if you are not planning on using MSI or Azure PowerShell.
if ($env:MSI_SECRET -and (Get-Module -ListAvailable Az.Accounts)) {
Disable-AzContextAutosave -Scope Process | Out-Null
$environmentName = (Get-AzEnvironment).Name
if ($environmentName)
{
Connect-AzAccount -Identity -Environment $environmentName
}
else
{
Connect-AzAccount -Identity
}
}
Can we use a variable from the Sandbox to figure out the environment?
I can't find the link but there was a recommendation to get rid of the -and ( Get-Module -ListAvailable Az.Accounts ) clause to reduce cold start delays