azure-functions-powershell-worker
azure-functions-powershell-worker copied to clipboard
Az.Accounts 2.1.0 and 2.1.2 fail to load into PowerShell session for run-from-package apps
When a Functions app is deployed in the run-from-package mode, upgrading Az.Accounts to 2.1.0 or 2.1.2 may cause the app to fail with messages indicating that the Az.Accounts is not loaded, for example:
-
The term 'X' is not recognized as the name of a cmdlet, function, script file, or operable program.
, whereX
is the name of a command defined in the Az.Accounts module. -
The Azure PowerShell context has not been properly initialized. Please import the module and try again.
These error messages are somewhat misleading. The Az.Accounts module is properly installed, but it cannot be loaded because it tries to write to the D:\home\site\wwwroot
directory, and this directory is mounted as read-only when the app is deployed in the run-from-package mode. Importing Az.Accounts explicitly (Import-Module Az.Accounts
) exposes the root cause:
-
Could not find file 'D:\home\site\wwwroot\.IdentityService'. Exception :Type : System.IO.FileNotFoundExceptionMessage
This is a regression in Az.Accounts 2.1.0 and 2.1.2
Workaround
Until the Az.Accounts module is fixed, please pin your app to Az.Accounts 1.9.5 by using the instructions in the first post of #552.
I can confirm that pinning Az.Accounts 1.9.5 is working perfectly fine. Thanks @AnatoliB
The problem is expected to be fixed in one of the next Az.Accounts releases, see https://github.com/Azure/azure-powershell/issues/13444
I wish this issue was easier to find! I spent a couple hours troubleshooting this issue on package deployments and finally found this issue.
Az.Accounts v2.1.2 does not work for me. I had to forcibly use v1.9.5 in the requirements.psd1 and profile.ps1 as outlined above:
The error I got on v2.1.2 was a file not found error for 'C:\home\site\wwwroot.IdentityService'
I'm looking forward to the next release!
The issue is supposedly fixed in Az.Accounts v2.2.1, which is available on the PowerShell Gallery now. If you were affected by the regression, please validate this. You may want to stop pinning Az.Accounts to any specific version now, so you take advantage of auto-upgrade again. But this is still a trade-off: auto-upgrade is convenient but introduces a certain risk of regressions.
Also, FYI: Postmortem of the Az 5.0 release