Azure / Azure/azure-functions-powershell-worker
Update profile.ps1 to include -ErrorAction Stop in Connect-AzAccount -Identity when the user authenticates with Azure PowerShell using an MSI
- Dominant language
- C#
- Stars
- 215
- Forks
- 61
- Avg merge
- 21h 4m
- Merged PRs (30d)
- 6
Description
I've investigated a CRI in which a worker VM went in a bad state and the function app experienced DNS resolution errors. As a result, the function could not connect to the Azure back end service.
We should update the `profile.ps1` to ensure that if `Connect-AzAccount -Identity` fails, the function execution stops. We can accomplish this by adding `-ErrorAction Stop`.
In addition, we should also consider adding a new line as a comment where the user sets the Azure PowerShell context to the required subscription.
```powershell
if ($env:MSI_SECRET) {
Disable-AzContextAutosave -Scope Process | Out-Null
Connect-AzAccount -Identity -ErrorAction Stop
# Get-AzSubscription -SubscriptionId -ErrorAction Stop | Set-AzContext -ErrorAction Stop
}
```
This template update should be applied to the Azure Portal, Core Tools, and VSCode Extension.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.