Azure / Azure/azure-functions-powershell-worker

Update profile.ps1 to include the Environment (if available) in Connect-AzAccount

Open
#649 2 comments 0 reactions 0 assignees View on GitHub
investigation P2
Dominant language
C#
Stars
215
Forks
61
Avg merge
21h 4m
Merged PRs (30d)
6

Description

This change will be required in all Functions' clients.

This is the current template:

```powershell
# 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:
```powershell
# 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
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.