Automate Data Export to Azure Monitor Logs

Below is an example PowerShell Runbook that can be used in an Azure automation account to export data from Microsoft Graph and send it to a Log Analytics workspace. It exports Windows devices with a selection of fields.

The following is assumed:

  • You have enabled a system managed identity for the Azure automation account and granted it the appropriate API permissions to Microsoft Graph.

  • You have created two encrypted variables in the automation account for the WorkspaceID and the PrimaryKey of your log analytics workspace.