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

Errors aren't logged in Azure Insights during initialization making it extremely hard to troubleshoot #237

Closed
restfulhead opened this issue Mar 15, 2024 · 2 comments

Comments

@restfulhead
Copy link

restfulhead commented Mar 15, 2024

If there's an issue with imports (say you reference a file that isn't available during runtime) or really any error in the "global" space, there is no error to be found in the Azure Insights log traces. This makes it extremely hard to troubleshoot.

Repro steps

Throw an error outside the function handler.

const { app } = require('@azure/functions');

if (!process.env.MY_VAR) {
    throw new Error('MY_VAR is not defined')
}

app.http('httpTrigger1', {
    methods: ['GET', 'POST'],
    authLevel: 'anonymous',
    handler: async (request, context) => {
        context.log(`Http function processed request for url "${request.url}"`);

        const name = request.query.get('name') || await request.text() || 'world';

        return { body: `Hello, ${name}!` };
    }
});

Expected behavior

I get the following log when using the emulator:

Worker was unable to load entry point "src/functions/httpTrigger1.js": MY_VAR is not defined

Actual behavior

However, when deployed to Azure, the error is not logged. We have no idea what went wrong. The end-result is that 0 functions were discovered and the function app is essentially empty.

0 functions loaded
Generating 0 job function(s)
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
HttpOptions { "DynamicThrottlesEnabled": true, "EnableChunkedRequestBinding": false, "MaxConcurrentRequests": 100, "MaxOutstandingRequests": 200, "RoutePrefix": "api" }
Initializing function HTTP routes No HTTP routes mapped

Workaround

Update: Ok, I set the logLevel of Azure.Core to Trace and then finally the error / stack trace is logged. Can the log level be fixed so the error gets logs as error or at least warning?

@ejizba
Copy link
Contributor

ejizba commented Mar 15, 2024

@restfulhead
Copy link
Author

@ejizba Oh didn't know about this setting, thank you. Will do and report back if there are any further issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants