Photo by Stephen Dawson on Unsplash

Member-only story

How to update a VM to Send to Log Analytics after Provisioning on Azure

Azure Powershell Gallery | Azure Modules | Azure VM | Log Analytics

βš— Kevin Summersill πŸ”‹
2 min readAug 11, 2021

--

There may be a need to quickly update a current Virtual Machine to utilize Log Analytics. This may be needed when declarative approaches do not work after provisioning. For example, setting up an ARM template with a VM and then updating it. This might be because the OSDisk (Operating System Disk) within the VM does not contain the agents and cannot be added. No worries this can be quickly done.

Pre-Requisites

  • Assumes that you already have a Log Analytics with a Workspace ID and Workspace Key.

Step 1. Install the Az.Compute Module

This is required as the PowerShell script utilizes the Set-AzVMExtention. So run the following:

Install-Module -Name Az.Compute

Step 2. Create a Powershell script

Create a file called β€œenable-log-analytics.ps1”. Add the following:

$PublicSettings     = @{"workspaceId" = "<your-workspace-id>"}
$ProtectedSettings = @{"workspaceKey" = "<your-workspace-key"}
Set-AzVMExtension -ExtensionName "MicrosoftMonitoringAgent" `…

--

--

βš— Kevin Summersill πŸ”‹
βš— Kevin Summersill πŸ”‹

Written by βš— Kevin Summersill πŸ”‹

Enterprise Solution Architect | Certified K8s Administrator/Developer βš“ | SAFe SPC | Cert Terraform | AWS Solutions Architect | Dev*Ops/GitOps Engineer πŸ”₯

No responses yet