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

Correct Way to Override host.json Logging Configuration for Application Insights #1491

Closed
BrandonSchreck opened this issue Apr 25, 2023 · 2 comments
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@BrandonSchreck
Copy link

BrandonSchreck commented Apr 25, 2023

We recently identified that several of our .NET 6 Isolated Process Azure Functions were not logging dependencies in Application Insights the same way our NodeJs Azure Functions were.

After some research, I found this pull request - #944 with steps to resolve this issue by utilizing Microsoft.Azure.Functions.Worker.ApplicationInsights v1.0.0-preview4. After migrating from Microsoft.ApplicationInsights.WorkerService I am now seeing the associated dependencies as with our NodeJs Azure Functions.

I've purposely left our host.json to use the default logging levels (Warning):

host.json

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            }
        }
    }
}

What I am wanting to accomplish is to update the Functions Configuration in the Azure Portal (or via PowerShell) by setting the logging level to Information and be able to see those logged Information messages in the Application Insights trace table.

However, setting either AzureFunctionsJobHost__logging__logLevel__default or AzureFunctionsJobHost__logging__logLevel__Function.{{FunctionName}} to Information doesn't seem to capture these logged messages. I double checked and verified that the Application Insights Connection String/Instrumentation Keys matched between the Azure Functions and the Application Insights instance. I also tried restarting the Azure Functions without any luck.

I am able to watch the Log Stream and see the Information/Trace logs being written out correctly.

Could someone provide the correct steps/settings to be able to ad-hoc increase the log level to capture additional logs?

@ghost ghost assigned jviau Apr 25, 2023
@jviau jviau added duplicate This issue or pull request already exists and removed Needs: Triage (Functions) labels Apr 25, 2023
@jviau
Copy link
Contributor

jviau commented Apr 25, 2023

host.json only affects the host process - not the worker process.

Take a look at #1182 for some steps on how to work with AppInsights logging in the worker.

For changing log settings in the portal, take a look at Azure AppConfiguration for your worker.

Changing environment variables will not dynamically update configuration, and externally changing environment variables of a running process is not recommended/doable.

@jviau jviau closed this as completed Apr 25, 2023
@BrandonSchreck
Copy link
Author

BrandonSchreck commented Apr 25, 2023

Changing environment variables will not dynamically update configuration, and externally changing environment variables of a running process is not recommended/doable.

Is that not what this article is referring to? If it is not recommended/doable, why do y'all have a tutorial?

@ghost ghost locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants