Thank you all for your help. I was able to resolve the problem
Issues with Entra Joined PC Logging Collection Setup
Details
Steps have been followed from the documentation at Azure Monitor Agent for Windows Client to set the monitored object and associate it with a DCR via PowerShell for Log Analytics, but there has been no success. Seeking guidance on troubleshooting this issue.
Azure Monitor
-
Srinivasa Reddy Jaggavarapu • 625 Reputation points • Microsoft External Staff
2025-04-16T08:02:23.44+00:00 Hi Al2020s,
To collect logs from an Entra-joined PC using Azure Monitor, you need to install the Azure Monitor Agent (AMA) on the PC, set up the PC as a monitored object in Azure, and link it to a Data Collection Rule (DCR) to define what data to collect. If you have followed Microsoft’s documentation but still not working, it could be due to a misconfiguration, a missed step, or permission issues that are preventing the setup from functioning correctly. Follow below steps to resolve the issue:
Make sure that the Azure Monitor Agent is installed on the PC and run the following PowerShell command to check:
Get-Service -Name azuremonitoragent
If the service isn’t running or installed, reinstall the agent using the documentation link: https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-windows-client#installing-the-agent
Confirm that the PC is correctly assigned to a Data Collection Rule and run this PowerShell command to verify the association:
Get-AzMonitorDataCollectionRuleAssociation -ResourceId "<ResourceID>"
Replace
<ResourceID>
with the resource ID of the PC. If the PC isn’t associated, ensure you have used the correct commands from the documentation.Make sure the PC and your Azure account have the required permissions to access Log Analytics and the DCR. Check permissions using Azure AD Role for confirming the PC is properly Entra-joined. and checking Log Analytics Workspace Access that your account must have at least Contributor access to the workspace.
If the above checks pass, review the local agent logs on the PC for errors and check for errors that may indicate connectivity or configuration issues by using below PowerShell:
Get-Content -Path "C:\ProgramData\AzureMonitorAgent\logs\*.log" -Tail 100
Verify that the PC can connect to Azure Log Analytics endpoints and replace
<LogAnalyticsRegion>
with the region of your Log Analytics workspace (e.g., "westus").Test-NetConnection -ComputerName <LogAnalyticsRegion>.ods.opinsights.azure.com -Port 443
Reference:
https://learn.microsoft.com/en-us/azure/azure-monitor/logs/manage-access?tabs=portal
Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
If the comment is helpful, please click "Upvote it".
-
Srinivasa Reddy Jaggavarapu • 625 Reputation points • Microsoft External Staff
2025-04-17T01:16:02.3233333+00:00 Hi Al2020s,
Just checking in to see if above information was helpful. If you have any further updates on this issue, please feel free to post back
-
Al2020s • 0 Reputation points
2025-04-17T17:14:58.5333333+00:00 Hi Srinivasa,
thank you for your comment. the issue I encountered was not the AMA agent installation on a Windows PC. I followed the instructions using powershell method (see below) with the only modification of changing the scope from "/" to specific resource group) but got stuck on step
of #Assign the Monitored Object Contributor role to the operator
I have subscription level owner role and Global Admin roles but getting msg of insufficient rights.https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-windows-client
-
Srinivasa Reddy Jaggavarapu • 625 Reputation points • Microsoft External Staff
2025-04-18T03:03:52.5133333+00:00 Hi Al2020s,
Thank you for clarifying the issue. From your description, it seems the challenge lies with assigning the Monitored Object Contributor role, despite holding Subscription Owner and Global Administrator roles.
This issue could occur because Azure Role-Based Access Control (RBAC) assignments sometimes require explicit permissions at the scope where the action is performed. Follow below steps to resolve the issue:
Make sure you are assigning the role at the correct scope. Since you are modifying the scope to a specific resource group, confirm that you have appropriate permissions at the resource group level. Even as a Subscription Owner, explicit permissions might be needed at the resource group level.
Use the following PowerShell command to validate your permissions at the resource group, also replace<SubscriptionID>
and<ResourceGroupName>
with the appropriate values.Get-AzRoleAssignment -Scope "/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroupName>"
If the required permission is not appearing in your role, assign the Monitored Object Contributor role at the resource group scope explicitly
New-AzRoleAssignment -ObjectId <UserObjectId> -RoleDefinitionName "Monitoring Contributor" -Scope "/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroupName>"
Replace
<UserObjectId>
with your Azure user ID.Sometimes, even with Global Admin privileges, role assignments at specific scopes might encounter restrictions. Verify that your account is not restricted by Privileged Role Management (PIM) policies or other AAD governance features.
After confirming the above steps, reattempt assigning the Monitored Object Contributor role.
Reference:
https://learn.microsoft.com/en-us/azure/azure-monitor/fundamentals/roles-permissions-security
https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal
Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
If the comment is helpful, please click "Upvote it".
-
Srinivasa Reddy Jaggavarapu • 625 Reputation points • Microsoft External Staff
2025-04-21T01:27:10.8366667+00:00 Hi Al2020s,
Just checking in to see if above information was helpful. If you have any further updates on this issue, please feel free to post back
-
Al2020s • 0 Reputation points
2025-04-21T17:59:54.5866667+00:00 thank you, but the role I am trying to assign is Monitoring Object Contributor on a scope of resource group and whatever I tried did not work.
-
Srinivasa Reddy Jaggavarapu • 625 Reputation points • Microsoft External Staff
2025-04-22T06:49:59.6366667+00:00 Hi Al2020s,
Ensure you are using the exact role name Monitoring Contributor (not "Monitored Object Contributor"). This built-in role grants permissions to manage monitoring resources. Reference Link: https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-steps
Even as a Subscription Owner or Global Administrator, explicit permissions might be required at the resource group level. Run this PowerShell command to check your current permissions:
Get-AzRoleAssignment -Scope "/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroupName>"
Replace
<SubscriptionID>
and<ResourceGroupName>
with your values and make sure your account hasMicrosoft.Authorization/roleAssignments/write
permission at the resource group scope.Azure CLI/PowerShell might fail to resolve your user's principal name due to Microsoft Entra lookup restrictions. Use your account’s object ID instead:
New-AzRoleAssignment -ObjectId "<YourObjectId>" -RoleDefinitionName "Monitoring Contributor" -Scope "/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroupName>"
Find your object ID via:
Get-AzADUser -UserPrincipalName "<YourUPN>"
Make sure the subscription hasn’t hit the 4,000 role assignments limit (unlikely but possible in large environments). Reference link: https://docs.azure.cn/en-us/role-based-access-control/troubleshoot-limits?tabs=default
Check if Azure Privileged Identity Management (PIM) or conditional access policies are blocking role assignments and ensure no custom policies are overriding permissions at the resource group level.
If permissions are still denied, re-register the
Microsoft.Authorization
resource provider. Reference link: https://learn.microsoft.com/en-us/archive/blogs/azure4fun/common-problem-when-using-azure-resource-groups-rbacRegister-AzResourceProvider -ProviderNamespace Microsoft.Authorization
Make sure that your account is explicitly listed as a "User Access Administrator" at the subscription or resource group level. Global Administrator roles in Entra ID do not automatically grant Azure RBAC permissions.
Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
If the comment is helpful, please click "Upvote it".
-
Alex Burlachenko • 4,310 Reputation points
2025-04-22T07:53:49.2133333+00:00 Dear Al2020s,
Thank you for reaching out and providing details about the challenges you’re encountering with the Entra Joined PC Logging Collection setup. I appreciate your effort in following the documentation and troubleshooting the issue thus far.
- Official Azure Monitor Agent (AMA) Documentation
Install the Azure Monitor Agent
- Troubleshooting Entra ID (Azure AD) Joined Devices
But if u preffer step by step , so StepbyStep :)
Step 1: Verify Azure AD Join Status
Run dsregcmd /status (Admin Command Prompt):
Check if AzureAdJoined = YES and TenantName is correct.
If issues exist, rejoin using:
dsregcmd /leave
dsregcmd /join
Step 2: Confirm Azure Monitor Agent (AMA) Installation
Check AMA service:
Get-Service -Name AzureMonitorAgent | Select-Object Status, StartType
If missing, install AMA:
Install-AzConnectedMonitorAgent -ResourceGroupName "<RG>" -MachineName "<PC-Name>"
Install AMA
Step 3: Validate Data Collection Rule (DCR) Association
List assigned DCRs:
Get-AzDataCollectionRuleAssociation -TargetResourceId "/subscriptions/<SubID>/resourceGroups/<RG>/providers/Microsoft.Compute/virtualMachines/<PC-Name>"
If none, associate manually:
New-AzDataCollectionRuleAssociation -TargetResourceId "<PC-ResourceID>" -RuleId "<DCR-ResourceID>"
Configure DCRs
Step 4: Check Log Ingestion Errors
AMA Troubleshooting Logs:
Path: C:\WindowsAzure\Logs\AzureMonitorAgent*.log
Look for errors like "Failed to send data" or "Access denied".
Test connectivity to Log Analytics:
Test-NetConnection -ComputerName "<Workspace>.ods.opinsights.azure.com" -Port 443
Step 5: Review Permissions
Ensure the device or MSI has:
Log Analytics Contributor on the workspace.
Monitoring Publisher role on the DCR.
AMA Permissions
If you're still facing issues, let me know the specific errors you're encountering, and I will try to help pinpoint the exact solution!
Best regards,
Alex
P.S.If my answer help to you, please Accept my answer
-
Srinivasa Reddy Jaggavarapu • 625 Reputation points • Microsoft External Staff
2025-04-23T01:33:28.09+00:00 Hi Al2020s,
Just checking in to see if above information was helpful. If you have any further updates on this issue, please feel free to post back
-
Al2020s • 0 Reputation points
2025-04-23T03:02:23.34+00:00 Hi,
the problem is not installing AMA agent on a physical PC.
The problem is creating a monitored object due to error of that my account does not have authorization rights
even though I have the following rights at subscription level
owner
global domain admin
Role Based Access Control Administrator
Monitoring Contributor
Log Analytics Contributor
I followed the steps for powershell option according to
https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-windows-client
And see my comments in boldI changed the scope from "/" to /subscriptions/xxxxx
#Grant access to the user at root scope "/"
$user = Get-AzADUser -SignedIn
#New-AzRoleAssignment -Scope '/' -RoleDefinitionName 'Owner' -ObjectId $user.Id
New-AzRoleAssignment -Scope '/subscriptions/xxxxxxxx' -RoleDefinitionName 'Owner' -ObjectId $user.Id#Create the auth token
$auth = Get-AzAccessToken
$AuthenticationHeader = @{
"Content-Type" = "application/json" "Authorization" = "Bearer " + $auth.Token }
#Assign the Monitored Object Contributor role to the operator
$newguid = (New-Guid).Guid
$UserObjectID = $user.Id
$body = @"
{
"properties": { "roleDefinitionId":"/providers/Microsoft.Authorization/roleDefinitions/56be40e24db14ccf93c37e44c597135b", "principalId": `"$UserObjectID`" }
}
"@
$requestURL = "https://management.azure.com/providers/microsoft.insights/providers/microsoft.authorization/roleassignments/$newguid`?api-version=2021-04-01-preview"
# but I am getting error executing this statement and can not proceed to the next step:
**Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body
#The error I am getting**
"error": {"code": "AuthorizationFailed",
"message": "The client ******@ecrypt.com\u0027 with object id \u00272c97fab4-eca5-4fe7-b10d-bdb69198492d\u0027 does not have authorization to perform action \u0027
microsoft.authorization/roleassignments/write\u0027 over scope \u0027/providers/microsoft.insights/providers/microsoft.authorization\u0027 or the scope is invalid. If access was
recently granted, please refresh your credentials."
##########################
#Create a monitored object
#The 'location' property value in the 'body' section should be the Azure region where the monitored object is stored. It should be the same region where you created the data collection rule. This is the region where agent communications occurs.
$Location = "eastus" #Use your own location
$requestURL = "https://management.azure.com/providers/Microsoft.Insights/monitoredObjects/$TenantID`?api-version=2021-09-01-preview"
$body = @"
{
"properties":{ "location":`"$Location`" }
}
"@
$Respond = Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body -Verbose
$RespondID = $Respond.id
##########################
#Associate a DCR to the monitored object
#See reference documentation https://learn.microsoft.com/rest/api/monitor/data-collection-rule-associations/create?tabs=HTTP
$associationName = "assoc01" #You can define your custom association name, but you must change the association name to a unique name if you want to associate multiple DCRs to a monitored object.
$DCRName = "dcr-WindowsClientOS" #Your data collection rule name
$requestURL = "https://management.azure.com$RespondId/providers/microsoft.insights/datacollectionruleassociations/$associationName`?api-version=2021-09-01-preview"
$body = @"
{ "properties": { "dataCollectionRuleId": "/subscriptions/$SubscriptionID/resourceGroups/$ResourceGroup/providers/Microsoft.Insights/dataCollectionRules/$DCRName" } }
"@
Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body
#(Optional example) Associate another DCR to a monitored object. Remove comments around the following text to use it as a sample.
#See reference documentation https://learn.microsoft.com/en-us/rest/api/monitor/data-collection-rule-associations/create?tabs=HTTP
<#
$associationName = "assoc02" #You must change the association name to a unique name if you want to associate multiple DCRs to a monitored object.
$DCRName = "dcr-PAW-WindowsClientOS" #Your Data collection rule name
$requestURL = "https://management.azure.com$RespondId/providers/microsoft.insights/datacollectionruleassociations/$associationName`?api-version=2021-09-01-preview"
$body = @"
{ "properties": { "dataCollectionRuleId": "/subscriptions/$SubscriptionID/resourceGroups/$ResourceGroup/providers/Microsoft.Insights/dataCollectionRules/$DCRName" } }
"@
Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body
#(Optional) Get all the associations.
$requestURL = "https://management.azure.com$RespondId/providers/microsoft.insights/datacollectionruleassociations?api-version=2021-09-01-preview"
(Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method get).value
#>
-
Srinivasa Reddy Jaggavarapu • 625 Reputation points • Microsoft External Staff
2025-04-23T10:38:32.35+00:00 Hi Al2020s,
The error indicates that the scope you’re trying to use (
/providers/microsoft.insights/providers/microsoft.authorization
) is invalid or not accessible with your permissions. For assigning roles such as Monitoring Object Contributor, ensure the scope is correct and points to a resource group or resource where the role needs to be assigned.While you have roles like Owner and Role-Based Access Control Administrator, ensure that your current session credentials are updated. Newly assigned roles sometimes require a refresh or re-login for the changes to take effect and there might be issues in the structure of your REST API body payload or headers, causing the request to fail.
- Confirm that your account has the required permissions to assign roles. Run the following PowerShell command to check:
Get-AzRoleAssignment -ObjectId $user.Id -Scope '/subscriptions/xxxx'
Make sure the role assignment scope is correct. If the monitored object resides in a specific resource group, the scope should be:
/subscriptions/{SubscriptionID}/resourceGroups/{ResourceGroupName}
- Update the role assignment script to use the correct scope and check for proper authorization:
$newguid = (New-Guid).Guid $scope = "/subscriptions/{SubscriptionID}/resourceGroups/{ResourceGroupName}" $roleDefinitionId = "/subscriptions/{SubscriptionID}/providers/Microsoft.Authorization/roleDefinitions/56be40e24db14ccf93c37e44c597135b" # Monitoring Object Contributor role ID $body = @" { "properties": { "roleDefinitionId": "$roleDefinitionId", "principalId": "$UserObjectID" } } "@ $requestURL = "https://management.azure.com{scope}/providers/Microsoft.Authorization/roleAssignments/$newguid?api-version=2021-04-01-preview" Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body
3.After updating roles, refresh your Azure credentials to ensure the changes propagate:
Disconnect-AzAccount Connect-AzAccount
4.Make sure that the region specified in the
location
field matches the region where the monitored object and data collection rule reside:$Location = "eastus" $requestURL = "https://management.azure.com/providers/Microsoft.Insights/monitoredObjects/$TenantID?api-version=2021-09-01-preview" $body = @" { "properties": { "location": "$Location" } } "@ $Respond = Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body
5.Once the roles are assigned, validate them using:
Get-AzRoleAssignment -ObjectId $UserObjectID -Scope $scope
Cross Check with below Documentation:
https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-rest
https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-windows-client
Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
If the comment is helpful, please click "Upvote it".
-
Al2020s • 0 Reputation points
2025-04-23T22:03:32.93+00:00 Thank you for your help.
I rechecked by roles at subsciption level and at resource group which are inherited from subscription role assignments:
Monitoring Contributor
Owner
Microsoft Sentinel Contributor
Log Analytics Contributor
Role Based Access Control Administratorgot error at this point (you actually suggeted a diffrent command then Miccrosoft
#$requestURL = "https://management.azure.com/providers/microsoft.insights/providers/microsoft.authorization/roleassignments/$newguid`?api-version=2021-04-01-preview"
PS C:\Windows\System32> $requestURL = "https://management.azure.com{scope}/providers/Microsoft.Authorization/roleAssignments/$newguid?api-version=2021-04-01-preview"
PS C:\Windows\System32> Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body
Invoke-RestMethod: Cannot bind parameter 'Uri'. Cannot convert value "https://management.azure.com{scope}/providers/Microsoft.Authorization/roleAssignments/-version=2021-04-01-preview" to type "System.Uri". Error: "Invalid URI: The hostname could not be parsed."
Sign in to comment
1 answer
Sort by: Most helpful
-
Al2020s • 0 Reputation points
2025-04-27T04:20:19.4433333+00:00