Open In App

How to Install MMA Agent for a Windows Virtual Machine using PowerShell?

Last Updated : 30 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisite:- Azure

Here in this article, we will show how to add or install MMA Agent on a Windows Virtual Machine in Azure using PowerShell. Before diving into the process let’s know what an MMA agent is. MMA Stands for Microsoft Monitoring Agent can be configured to collect the performance logs or the application logs of an Azure Virtual Machine by connecting it to Log Analytics Workspace in Azure. 

Steps to configure MMA Agent on Windows VM

Step 1: Log in to Azure Portal.

Step 2: Access the Azure Cloud Shell and Switch to the PowerShell console

 Azure Cloud Shell

 

Step 3: Now Use the below command to create a new file named installMMAAgent.ps1

touch installMMAAgent.ps1

Step 4: use the command to write the code in the newly created file:installMMAAgent.ps1

code installMMAAgent.ps1
powershell

 

Step 5: Paste the below-following code in the install MMAAgent.ps1 file

$subName = "<default subscription name>"
Select-AzSubscription -Subscription $subName

$workspaceRG = "<resource group name>"

$workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $workspaceRG
$workspaceId = $workspace.CustomerId
$workspaceKey = Get-AzOperationalInsightsWorkspaceSharedKeys 
-ResourceGroupName $workspaceRG -Name $Workspace.Name
$Publicsettings=@{"workspaceId" = $workspaceId}
$Protectedsettings=@{"workspaceKey" = $workspaceKey.primarysharedkey}

Set-AzVMExtension 
      -ExtensionName "Microsoft.EnterpriseCloud.Monitoring" `
      -ResourceGroupName "<add VM resource group> `
      -VMName "<add server name>" `
      -Publisher "Microsoft.EnterpriseCloud.Monitoring" `
      -ExtensionType "MicrosoftMonitoringAgent" `
      -TypeHandlerVersion 1.0 `
      -Settings $PublicSettings `
      -ProtectedSettings $ProtectedSettings `
      -Location "<location name>"
code

 

Step 6: Save the file and run the code. Use the following command to run the code.

./installMMAAgent.ps1
save and run file

 

Step 7: Go to your target Azure VM and check the Extensions + applications. You should see this “MicrosoftMonitoringAgent” extension on Azure VM if successful.

azure vm

 

This is how you can install a Microsoft Monitoring Agent (MMA) extension for a Windows Virtual Machine in Microsoft Azure.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads