Reputation: 41
we have a function app with a blob trigger. Recently, I've migrated the trigger to an identity-based authentication according to this documentation. It works well locally on my machine and on the function app. Note that the app is written in Python. Although, the error happens before the app is called so I doubt that language is a factor here.
My colleague recently started to collaborate on the function. When he tried to debug locally, he had this error as soon as he tried to launch the function (when the function would connect to the queue service for the triggers)
An unhandled exception has occurred. Host is shutting down. Azure.Identity: Azure PowerShell authentication failed due to an unknown error. 'az' is not recognized as an internal or external command, operable program or batch file.
I told him to install the Azure CLI and the error switched to:
An unhandled exception has occurred. Host is shutting down. Azure.Identity: Azure PowerShell authentication failed due to an unknown error. 'pwsh' is not recognized as an internal or external command, operable program or batch file.
The error clearly seems to be a missing powershell core CLI. What bugs me is that, apart from the windows-bundled powershell, pwsh is not a recognized command on my machine also. Therefore, I should be getting this error but I'm not while my colleague is.
Here's what we tried:
We work on Windows 10 19044
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 5.0.0)"
},
"functionTimeout": "00:55:00",
"extensions": {
"blobs": {
"maxDegreeOfParallelism": 1
},
"queues": {
"batchSize": 1,
"newBatchThreshold": 0
}
}
}
function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "PROJECT/documents/{name}",
"connection": "PROJECT"
}
]
}
Upvotes: 2
Views: 1374
Reputation: 41
I figured it out by reading this.
The authentification goes through the Azure CLI when it fails to get user context from VSC. So, this explains why my colleague and I had different results. For me, the program would authenticate using my VSC credentials while it didn't work for my colleague.
To solve this, we:
az login
to make sure it was working properlyCan't say for sure that it's the first step that solved it but it's solved.
Upvotes: 2
Reputation: 905
One of the possible reasons for this error the user (or system) PATH environment variable not containing the directory where the PowerShell executable located. It's usually located at C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
, and although the PATH variable contains the C:\Windows\System32
directory, Windows may have problems finding the executable within its subfolders.
The solution entails setting the PATH environment variable to the directory where the PowerShell executable is located.
Upvotes: 0