Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below are step‑by‑step console instructions to fix “Monitoring Agent is not provisioned” in Azure Security Center (now Microsoft Defender for Cloud).The goal:
If you tell me whether your recommendation mentions Azure Monitor Agent or the older Log Analytics agent, I can tailor the exact steps to that specific case.
- Have a Log Analytics workspace, and
- Enable the Azure Monitor Agent (or MMA, depending on your setup) on all relevant resources so Defender for Cloud can collect data.
1. Verify / Create a Log Analytics Workspace
- Sign in to the Azure portal: https://portal.azure.com
- In the left menu, search for and select Log Analytics workspaces.
- Check if you already have a workspace you want to use for Defender for Cloud.
- If yes, note its name and region and skip to section 2.
- If not, create one:
- Click + Create.
- Choose Subscription and Resource group.
- Enter a Name and choose a Region.
- Click Review + create → Create.
2. Enable Auto‑Provisioning of the Monitoring Agent (Recommended)
- In the Azure portal, search for and select Microsoft Defender for Cloud (or Security Center if still labeled).
- In the left pane, select Environment settings (or Getting started → Upgrade if you haven’t enabled Defender plans).
- Select the Subscription you want to configure.
- In the subscription blade, go to Auto-provisioning (sometimes under Settings).
- Find:
- Log Analytics agent for Azure VMs (legacy MMA) and/or
- Azure Monitor Agent (newer recommended agent).
- Set Auto-provisioning to On for the relevant agent.
- For each enabled agent, select the Log Analytics workspace you created or verified earlier.
- Click Save.
3. Manually Install the Agent on Specific VMs (If Needed)
Use this if you don’t want to enable auto‑provisioning or need to fix specific VMs immediately.3.1 Azure Monitor Agent (preferred)
- In the Azure portal, go to Virtual machines.
- Select the VM that shows the recommendation.
- In the VM blade, select Extensions + applications.
- Click + Add.
- Choose AzureMonitorWindowsAgent or AzureMonitorLinuxAgent (depending on OS).
- In the configuration:
- Select the Region and Data Collection Rule (DCR) if prompted.
- If you don’t have a DCR, you may need to create one (under Azure Monitor → Data collection rules) and associate it with your Log Analytics workspace.
- Click Review + create → Create.
- Wait for the extension to show as Provisioning succeeded.
3.2 Log Analytics Agent (legacy MMA, if that’s what your environment uses)
- In Virtual machines, select the VM.
- Go to Extensions + applications.
- Click + Add.
- Select Log Analytics agent (OMS) or similar name.
- In the configuration:
- Pick the Log Analytics workspace.
- Click Review + create → Create.
- Wait for provisioning to complete.
4. Confirm Remediation in Defender for Cloud
- Go back to Microsoft Defender for Cloud.
- In the left pane, select Recommendations.
- Find the recommendation like “Monitoring agent should be installed on your virtual machines” (or similar).
- Open it:
- The list of affected resources should shrink as agents finish installing.
- Status moves from Unhealthy to Healthy once Defender detects the agent.
If you tell me whether your recommendation mentions Azure Monitor Agent or the older Log Analytics agent, I can tailor the exact steps to that specific case.
Using CLI
Using CLI
Below are CLI-only steps to remediate the “Monitoring agent is not provisioned” recommendation in Azure Security Center (Defender for Cloud) by installing the Log Analytics agent and enabling auto‑provisioning.
Get workspace info (needed later for the agent):
This alone will remediate most future “Monitoring agent is not provisioned” findings.
Tasks related to those VMs should disappear or move to “resolved” once the agent is detected.
1. Log in and select subscription
2. Create (or identify) a Log Analytics workspace
If you already have one, skip to step 3. To create:3. Connect Defender for Cloud to the workspace
4. Enable auto‑provisioning of the monitoring agent
This lets Defender for Cloud automatically install the agent on supported VMs:5. (Optional) Manually install the agent on existing VMs
If you want to remediate immediately on specific VMs instead of waiting for auto‑provisioning:For Windows VMs
For Linux VMs
6. Verify in Azure Security Center
After a few minutes:Using Python
Using Python
Below are two common Python-based remediation paths for “Monitoring agent is not provisioned” in Azure Security Center (Defender for Cloud):
Run this once per subscription where the recommendation appears.
After a few minutes, Azure Security Center will start provisioning the monitoring agent on supported machines.
You also need:Run this for each VM that is missing the monitoring agent.
After deployment, Azure Security Center should mark the recommendation as resolved for that VM (allow some time for evaluation).
- Turn Auto-Provisioning ON (recommended – Security Center will deploy the agent to supported VMs).
- Manually install the Monitoring Agent extension on specific VMs.
1) Enable Auto-Provisioning of the Monitoring Agent (Python + REST)
This tells Azure Security Center to automatically deploy the Log Analytics / Monitoring agent to supported VMs.Prerequisites
pip install azure-identitypip install requests- An Azure AD app or logged-in environment that
DefaultAzureCredentialcan use. - Your subscription ID.
Python script
After a few minutes, Azure Security Center will start provisioning the monitoring agent on supported machines.
2) Manually Install the Monitoring Agent on a VM (Python SDK)
Use this if you want immediate remediation on specific VMs or do not want global auto‑provision.Prerequisites
- Subscription ID
- Resource group name
- VM name
- Workspace ID and key for Log Analytics (where the agent should send logs)
Python script (Windows or Linux VM)
After deployment, Azure Security Center should mark the recommendation as resolved for that VM (allow some time for evaluation).
Using Terraform
Using Terraform
- Replace
MY_VMwith your VM resource name andMY_WORKSPACEwith yourazurerm_log_analytics_workspaceresource. - This installs the Azure Monitor Agent extension required for Azure Security Center; only the extension resource is created/updated (the VM itself is not replaced).
terraform plan should show one azurerm_virtual_machine_extension.azure_monitor_agent to be created (or updated) and no VM replacement.
