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

Azure Function not loaded with specific host settings - logging #6660

Open
1 task done
petrkasnal opened this issue Nov 13, 2024 · 6 comments
Open
1 task done

Azure Function not loaded with specific host settings - logging #6660

petrkasnal opened this issue Nov 13, 2024 · 6 comments
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-functions Issues related to the Azure Functions integration

Comments

@petrkasnal
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I use the Azure Function in Aspire, a strange behavior occurs when I have this block in host.json. It happened in the previous version 9.0 as I mention here and it happens now in version 9.1.0-preview.1.24561.5.

What happens is that Aspire starts and shows the function loading, which eventually doesn't load and after 120 seconds it throws Failed to start. I used the example repository for Azure Function in Aspire.

I prepared repository - https://github.com/petrkasnal/AspireHostProblem

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "Default": "Debug", // If enable function isnt load
      "System": "Information",
      "Microsoft": "Information"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "enableLiveMetricsFilters": true
    }
  }
}
fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      timeout of 120 seconds exceeded waiting for the IDE to start a run session; you can set the DCP_IDE_REQUEST_TIMEOUT_SECONDS environment variable to override this timeout (in seconds)    {"Executable": {"name":"funcapp-czmfpfza"}, "Reconciliation": 2, "error": "Put \"https://localhost:64604/run_session?api-version=2024-04-23\": context deadline exceeded"}

Image

Expected Behavior

I would expect the logging settings to have no effect on Azure function execution. It's holding us back now because I have to keep overwriting it and that's not very convenient.

Steps To Reproduce

Open repository - https://github.com/petrkasnal/AspireHostProblem
Run AzureFunctionsTest.AppHost project

If you edit host.json - comment line "Default": "Debug" and starts work

Exceptions (if any)

No response

.NET Version info

9.0.0-rc.2.24473.5

Anything else?

No response

@captainsafia
Copy link
Member

@petrkasnal Thanks for reporting this issue! I took at stab and trying your repro and noticed the following exception at startup:

Microsoft.Azure.WebJobs.Extensions.EventHubs: EventHub account connection string with name 'eventhubs' does not exist in the settings. Make sure that it is a defined App Setting.

I believe this is related to the fact that the eventHubs resource is not configured by default in your sample:

builder.AddAzureFunctionsProject<Projects.AzureFunctionsTest_Functions>("funcapp")
    .WithReference(messaging)
    .WithReference(messaging2)
    .WithReference(messaging3)
    .WithReference(messaging4)
    .WithReference(messaging5)
    .WithReference(messaging6);
    //.WithReference(eventHubs);
    //.WithReference(serviceBus);

Once I re-enable the event hubs resource, things seem to work fine there.

You also mentioned that you're seeing the following DCP exception:

fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      timeout of 120 seconds exceeded waiting for the IDE to start a run session; you can set the DCP_IDE_REQUEST_TIMEOUT_SECONDS environment variable to override this timeout (in seconds)    {"Executable": {"name":"funcapp-czmfpfza"}, "Reconciliation": 2, "error": "Put \"https://localhost:64604/run_session?api-version=2024-04-23\": context deadline exceeded"}

In the past, I've seen this happen when the functions process fails to start. This might be related to the issues you are seeing in #6661. Do you repro this when launching from the command line via dotnet run?

@captainsafia captainsafia added area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-functions Issues related to the Azure Functions integration labels Nov 14, 2024
@petrkasnal
Copy link
Author

I edited the repository. I left really just the function execution to show that it doesn't matter if something is attached to it.

builder.AddAzureFunctionsProject<Projects.AzureFunctionsTest_Functions>("funcapp");

If the Aspire starts, the function doesn't run. If a line is added to host.json as in the specification - "Default": "Debug", it will start immediately. Try and see. Issue #6661 is related to a different problem and is mine.

I just tried using dotnet run and unfortunately I don't use it, so I don't know if I'm doing it right. But it throws me this error in the console.I started the dotnet run project in Aspire. I don't think that has anything to do with it.

2024-11-14T10:26:57
 Unhandled exception: System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'func' with working directory 'bin\Debug\net8.0\'. The system cannot find the file specified.
2024-11-14T10:26:57
    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
2024-11-14T10:26:57
    at Microsoft.DotNet.Cli.Utils.Command.Execute(Action`1 processStarted)
2024-11-14T10:26:57
    at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
2024-11-14T10:26:57
    at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
2024-11-14T10:26:57
    at System.CommandLine.ParseResult.Invoke()
2024-11-14T10:26:57
    at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

@captainsafia
Copy link
Member

@petrkasnal Can you verify what version of the Azure Functions Core Tools you are using? Running:

> func --version

should get this info.

@petrkasnal
Copy link
Author

@captainsafia sure - 4.0.5907

@captainsafia
Copy link
Member

@petrkasnal Ah, I see. Your version is about 6 months old. Can you try upgrading to the latest? It should be 4.6610.

@petrkasnal
Copy link
Author

@captainsafia I promoted the version. However, it didn't help, it's still the same.I tried running from visual studio and using dotnet run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-functions Issues related to the Azure Functions integration
Projects
None yet
Development

No branches or pull requests

2 participants