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

[BUG] Dotnet Azure Function Not captured in elastic #2407

Open
Elsakrishi29 opened this issue Aug 7, 2024 · 3 comments
Open

[BUG] Dotnet Azure Function Not captured in elastic #2407

Elsakrishi29 opened this issue Aug 7, 2024 · 3 comments
Labels
bug Something isn't working community triage

Comments

@Elsakrishi29
Copy link

Elsakrishi29 commented Aug 7, 2024

We followed this link to add elastic dotnet apm agent to our azure function.

The functions are not captured in elastic, then I didn't get any logs in my azure cloud function. ( After integrating the Elastic APM tracing middleware into my Azure Functions app, the function executes successfully but does not return any data or response when accessing the endpoint. The function works correctly when the middleware is not included )

Agent instrumentation (Program.cs)

using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Elastic.Apm.Azure.Functions;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults(builder =>
    {
        builder.UseMiddleware<ApmMiddleware>();
    })
    .ConfigureFunctionsWebApplication()
    .ConfigureServices(services => {
        services.AddApplicationInsightsTelemetryWorkerService();
        services.ConfigureFunctionsApplicationInsights();
    })
    .Build();

host.Run();

Could someone please help me figure out why this error is occurring?

@Elsakrishi29 Elsakrishi29 added the bug Something isn't working label Aug 7, 2024
@Mpdreamz
Copy link
Member

Thanks for bringing this to our attention @Elsakrishi29 do you get any azure logs from the invocation?

@Elsakrishi29
Copy link
Author

Every time I add Elastic configuration to my application, it fails to work properly.

If i removed those configuration in my application it will work fine

logs

Connected!
2024-08-16T07:49:16Z   [Information]   Executing 'Functions.HttpExample' (Reason='This function was programmatically called via the host APIs.', Id=b65075f0-c5bc-45ec-a878-2f022a4132e1)
2024-08-16T07:49:16Z   [Information]   Executed 'Functions.HttpExample' (Succeeded, Id=b65075f0-c5bc-45ec-a878-2f022a4132e1, Duration=19ms)
2024-08-16T07:49:41Z   [Information]   Executing 'Functions.HttpExample' (Reason='This function was programmatically called via the host APIs.', Id=b9b094ec-2991-4ff3-a208-5146a7de5b50)
2024-08-16T07:49:41Z   [Information]   Executed 'Functions.HttpExample' (Succeeded, Id=b9b094ec-2991-4ff3-a208-5146a7de5b50, Duration=4ms)
2024-08-16T07:49:41Z   [Information]   Executing 'Functions.HttpExample' (Reason='This function was programmatically called via the host APIs.', Id=38e5d51d-8813-477f-9273-cba982f37d0e)
2024-08-16T07:49:41Z   [Information]   Executed 'Functions.HttpExample' (Succeeded, Id=38e5d51d-8813-477f-9273-cba982f37d0e, Duration=3ms)

Configuration

dotnetelasticapp-Microsoft-Azure

@th3ragex
Copy link

Seems to be a duplicate of #2311

    .ConfigureFunctionsWorkerDefaults(builder =>
    {
        builder.UseMiddleware<ApmMiddleware>();
    })
    .ConfigureFunctionsWebApplication() -> calls "ConfigureFunctionsWorkerDefaults" internally too

Does it work without the ConfigureFunctionsWebApplication call?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community triage
Projects
None yet
Development

No branches or pull requests

3 participants