Step 1: Create a Log Analytics workspace.
First create the workspace.
Step 2: Add a VMInsights solution.
Before a Log Analytics workspace can be used with VM insights, it must have the VMInsights solution installed.
Step 3: Install agents on the VM and VM scale set to be monitored.
Prior to onboarding agents, you must create and configure a workspace. Install or update the Application Insights Agent as an extension for Azure virtual machines and VM scalet sets.
Step 4: Create an Application Insights resource
Sign in to the Azure portal, and create an Application Insights resource.

Once a workspace-based Application Insights resource has been created, configuring monitoring is relatively straightforward.
Reference:
https://docs.microsoft.com/en-us/azure/azure-monitor/vm/vminsights-configure-workspace
https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-workspace-resource