Skip to main content

Logging Provider: Azure Log Analytics

What are Logging Providers?

Logging to Azure Log Analytics

Description

A Logging Provider that enables to user to send messages straight to an Azure Log Analytics workspace. Requires you to have already configured a target workspace to log to.

Stats

NameAzureLogAnalytics
Version2
ConfigurationRootPSFramework.Logging.AzureLogAnalytics
Supports DataFalse
InstallationNot Required

Properties

Properties are used to control the behavior of the Provider. They can be specified using Set-PSFLoggingProvider or provided using the Configuration system.

NameDefault ValueDescription
WorkspaceIdWorkspaceId for the Azure Workspace we are logging our data objects to.
SharedKeySharedId for the Azure Workspace we are logging our data objects to.
LogType'Message'Log type we will log information to.

Log Analytics and Azure Functions

If you are trying to log using PSFramework while inside an Azure Function App, there is one additional catch: By default, logging is disabled in Function Apps, as it might keep the Function App running after the main script is done, creating unexpected overhead (and thus costs).

To enable it, run:

Start-PSFRunspace -Name psframework.logging

When your code is done, be sure to disable it again avoid aforementioned costs:

# Wait for logging to complete
Wait-PSFMessage

# Stop logging runspace
Stop-PSFRunspace -Name psframework.logging

Notes

This Logging Provider currently does not support special proxy handling. In order to successfully log to Azure Log Analytics, default connectivity must succeed.