azure-tools-for-intellij
azure-tools-for-intellij copied to clipboard
Unable to debug dotnet-isolated Azure Function with specific logging configuration
Hi, I cannot debug my dotnet-isolated Azure Function (.NET 6) locally. After successful build the process runs a long time with the status
Waiting for Azure Functions host to start...
... and then ends with the following error message.
Azure Functions host did not return isolated worker process id. Could not attach the debugger. Check the process output for more information.
When I start the debugging from terminal I am able to attach to the process in Rider without a problem. So I guess this issue is somehow related to the tooling.
Here is my environment: Windows 11 JetBrains Rider 2022.1.1 Azure Toolkit for Rider 3.50.0.1413-2022.1
Strange observation I made when trying to narrow down the problem. As soon as I configure any log level with a higher severity than Information for the host in my host.json the debugging fails with the above mentioned error. When I set the value to Information or any other lower severity the debugging is working fine. At this point I am not sure whether this is the root cause but it is definitely strange...
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"logLevel": {
"default": "Warning",
"Host": "Error", <-- this breaks the debugging
"Function": "Information"
}
}
}
If you need any more information I am glad to provide it. Thanks in advance!
When I start the debugging from terminal I am able to attach to the process in Rider without a problem.
For Rider, we pass the --dotnet-isolated-debug command line argument, so the worker process ID is emitted to console and we can automatically attach. I tried your repro scenario, and indeed: when log level is specified, no process ID is emitted and Rider can't attach.
I've created an issue with the Azure Functions repo here, as we need the PID to be able to attach the debugger: https://github.com/Azure/azure-functions-dotnet-worker/issues/900
For now, I would recommend keeping the host logging set to Information, let's wait for the Azure Functions team to respond.
Thanks for the quick reply and the issue at the Azure Functions repo. I'll keep an eye on it.
In the meantime I figured out a workaround, which maybe helps others. So I will leave this information here. You are able to overwrite host.json values with local.settings.json, so that you are able to debug the function locally without modifying the host.json file.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AzureFunctionsJobHost:Logging:LogLevel:Host": "Information" <-- this overwrites the host log level
}
}
That's a really good find, thank you @LarsBauer !
~~I'm having a similar issue, but my host log logging definition is somewhat different:~~ sorry, not relevant to this issue.