Firstly let us ask the question,
What is Azure Monitor?
Azure Monitor is a tool to collect your data(logs) from both on-premises and Azure servers and to analyse these logs and provide detailed dashboards to show performance and availability of your applications hosted on these servers.
Next we ask ourselves how and where does this data get sent to?
The easy answer is that is gets ingested(collected) into a Log Analytics workspace, which is a storage space for this data.
How does this data get ingested?
You install a dependency agent on the machines that you wish to collect logs from.
Now we come to the main reason for this blog, what happens if there is either a problem installing this agent or Azure Monitor doesn’t recognise the machine the agent has been installed on to?
If either of these issues exist then you must manually deploy the Azure VM Dependency agent virtual machine extension for Windows and this is done by the following steps using the PowerShell deployment method ( this can also be deployed by an Azure Resource Manager template, but not documented here):
Open either Azure CloudShell or PowerShell on a machine that is capable of connecting remotely to the Azure portal.
Run the following PowerShell command remembering to amend the following lines, -ResourceGroupName, -VMName and finally -Location to their respective locations.
Set-AzVMExtension -ExtensionName “Microsoft.Azure.Monitoring.DependencyAgent” `
-ResourceGroupName “myResourceGroup” `
-VMName “myVM” `
-Publisher “Microsoft.Azure.Monitoring.DependencyAgent” `
-ExtensionType “DependencyAgentWindows” `
-TypeHandlerVersion 9.10 `
-Location WestUS
This will now install the agent extension and you must wait for 5-10 minutes for it to take effect, then check within Azure Monitor that the VM you need data collecting from is reporting in correctly.