Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
Go to the Azure Portal
In the left-hand menu, click on "Virtual Machines" and select the VM you want to connect to the Log Analytics Workspace.
On the VM's overview page, scroll down to the "Monitoring" section in the menu and click on "Insights" depending on what's available. If there's an option to enable monitoring, proceed to enable it, which will install the required agents.
If this option is not visible, go to "Extensions" under the "Settings" section in the VM's menu. Click "+ Add" to add a new extension, search for "Azure Monitor" or "Log Analytics Agent," and select it. Follow the prompts to install the agent. During installation, you'll be asked to select the Log Analytics Workspace to connect to; choose your workspace and continue.
After installation, return to the Log Analytics Workspace and go to "Logs" or "Virtual Machines" under the "Monitoring" section. Your VM should appear in the list of connected resources, though it might take a few minutes for data to show up.
To configure the logs and performance data you want to collect, go to the Log Analytics Workspace, click "Settings," then "Agents configuration" or "Data collection." From there, you can select the logs and performance counters you wish to monitor from your VM.
https://learn.microsoft.com/en-us/azure/azure-monitor/agents/agent-windows?tabs=setup-wizard
https://learn.microsoft.com/en-us/azure/azure-monitor/logs/log-analytics-overview
let us know if any help, we will always help as you needed.!
Please do not forget to "Accept the answer” and upvote it wherever the information provided helps you, this can be beneficial to other community members.it would be greatly appreciated and helpful to others.