This PowerShell script streamlines onboarding Azure resources into Azure Monitor and Log Analytics, helping you quickly centralize logs, enable diagnostics, and understand your monitoring coverage across a subscription.
To run the script, copy & paste the Main file into Azure Cloud Shell's Powershell.
After running the script, it'll take 90~ minutes for data to start being pulled.
To confirm the Diagnostic settings & Log Analytics are configured correctly:
- Go into an indivisual resource --> Monitor (side panel) --> Diagnostic Settings.
In there, you should see a Diagnostic Setting with the Log Analytics Workspace you targetted during your script run.
The script guides you through discovering (or creating) a Log Analytics Workspace (LAW), then scans your Azure subscription to connect supported resources, enable diagnostics, and export visibility into the results.
High-Level Workflow
Scans the Azure subscription currently connected to PowerShell for existing Log Analytics Workspaces.
Prompts you to choose:
- Create a new LAW
- Use an existing LAW
If creating a new LAW:
- Option to create a new Resource Group (RG)
- Use an existing RG
Guided naming prompts for:
- Log Analytics Workspace
- Resource Group (if needed)
If using an existing LAW:
- The script lists all available workspaces
- You select which one to use
If creating a new LAW:
- The script provisions it using the naming inputs you provide
Enumerates all resources in the connected Azure subscription.
For each resource, the script:
- Determines whether it is Azure Monitor–compatible
- Checks whether Diagnostic Settings are already enabled
- Checks whether it is already connected to a Log Analytics Workspace
For resources that support Azure Monitor:
- Connects the resource to the selected Log Analytics Workspace
- Enables Diagnostic Settings (logs)
- Skips resources that are:
Not Azure Monitor compatible
- Already configured (to avoid duplicates)
Output: Resource Visibility Report (CSV)
At the end of the run, the script generates a downloadable CSV report that provides visibility into your environment.
The CSV includes:
- Whether the resource is Azure Monitor compatible
- Whether Diagnostic Settings are enabled
- Whether the resource is connected to a Log Analytics Workspace
- Whether logs are actively being sent
This makes it easy to:
- Audit monitoring coverage
- Identify gaps
- Share results with security, compliance, or operations teams
Benefits
- Simplifies Azure Monitor onboarding
- Reduces manual configuration and guesswork
- Provides clear, exportable visibility into monitoring state
- Works across an entire Azure subscription
Ideal Use Cases
- Cloud hygiene and observability audits
- Standardizing diagnostics across environments
Requirements
- Initial Azure subscription & Azure resources setup
- Azure PowerShell (Az modules)
Permissions to:
- Read Azure resources
- Create or manage Log Analytics Workspaces
- Configure Diagnostic Settings