Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to debug dotnet-isolated Azure Function with specific logging configuration #595

Open
LarsBauer opened this issue May 16, 2022 · 5 comments
Labels
wontfix This will not be worked on

Comments

@LarsBauer
Copy link

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!

@maartenba maartenba added the wontfix This will not be worked on label May 17, 2022
@maartenba
Copy link

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: Azure/azure-functions-dotnet-worker#900

For now, I would recommend keeping the host logging set to Information, let's wait for the Azure Functions team to respond.

@LarsBauer
Copy link
Author

LarsBauer commented May 18, 2022

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
    }
}

@maartenba
Copy link

That's a really good find, thank you @LarsBauer !

@maartenba maartenba changed the title Unable to debug dotnet-isolated Azure Function Unable to debug dotnet-isolated Azure Function with specific logging configuration May 20, 2022
@SeanFeldman
Copy link

SeanFeldman commented Aug 5, 2022

I'm having a similar issue, but my host log logging definition is somewhat different:
sorry, not relevant to this issue.

@abhith
Copy link

abhith commented Nov 6, 2024

It seems the Azure issue has been resolved, but the problem with Rider is still ongoing. I tried updating host.json and local.settings.json, but it didn’t help.

It seems it worked after editing host.json and local.settings.json files and then restarting Rider.

net8.0
Windows 11
JetBrains Rider 2024.2.7
Azure Toolkit for Rider 4.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants