azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Problem with Get-AzureRmLog. Caller information is not displayed.

Open karun-r opened this issue 9 years ago • 12 comments

Cmdlet

Get-AzureRmLog

PowerShell Version

5.0.10586.117

Module Version

4.3.1 (Although I have other versions coexist in the box)

OS Version

10.0.10586.117

Description

I used to get the user who initiated a event when I query Get-AzureRmLog cmdlet. But, since yesterday, we observe that we are not getting the user information in the event.

Debug Output

Scrubbed version. { "authorization": { "action": "Microsoft.Compute/virtualMachines/extensions/write", "scope": "/subscriptions//resourcegroups//providers/Microsoft.Compute/virtualMachines//extensions/BGInfo" }, "correlationId": "", "category": { "value": "Administrative", "localizedValue": "Administrative" }, "id": "/subscriptions//resourcegroups//providers/Microsoft.Compute/virtualMachines//extensions/BGInfo/events//ticks/", "resourceGroupName": "", "operationName": { "value": "Microsoft.Compute/virtualMachines/extensions/write", "localizedValue": "Microsoft.Compute/virtualMachines/extensions/write" }, "status": { "value": "Accepted", "localizedValue": "Accepted" }, "subStatus": { "value": "", "localizedValue": "" }, "eventTimestamp": "2017-10-18T13:17:58.2855259Z", "subscriptionId": "" }

Script/Steps for Reproduction

Code that I am using

$ActivityLog = Get-AzureRmLog -StartTime ([DateTime]::Now - [TimeSpan]::FromHours(24)) -EndTime ([DateTime]::Now) 
$VMCreateLog = $ActivityLog | Where-Object {$_.Authorization.Action -eq 'Microsoft.Compute/VirtualMachines/write'}

After initialization of the $VMCreateLog, I've set a breakpoint to observe the records and below is a sample. capture

karun-r avatar Oct 18 '17 21:10 karun-r

@gucalder Hey Guillermo, would you mind taking a look at this issue? It looks like the property in question is still available from the output, but it is not being populated.

cormacpayne avatar Oct 19 '17 16:10 cormacpayne

@karun-r what was the previous version you were using that was returning a value for the Caller property?

cormacpayne avatar Oct 19 '17 16:10 cormacpayne

@cormacpayne It should be the same version as I didn't do any update to the modules in a month. This cmdlet was working as expected till a couple of days back.

karun-r avatar Oct 20 '17 14:10 karun-r

And one more quick thing @cormacpayne , you mentioned in our previous comment that the value for caller is available from the output but I'm just puzzled on where you saw that in the debug output? Did you run the cmdlet it on any of the subscription available to you or is there any other source for this that I am missing? Would you mind sharing some light on that?

karun-r avatar Oct 20 '17 18:10 karun-r

@karun-r in both the picture you posted above and my execution of Get-AzureRmLog, there is a Caller property that is in the output (part of the object returned) that has no value.

PS C:\> $logs = Get-AzureRmLog
PS C:\> $logs[0]

Authorization     :
Caller            :
CorrelationId     : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Category          : ServiceHealth
EventTimestamp    : 10/20/2017 1:17:34 AM
OperationName     : RCA - Azure Management Portal [Multi-Region]
ResourceGroupName :
ResourceId        :
Status            : Resolved
SubscriptionId    : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
SubStatus         :

PS C:\> $logs[0].GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    PSEventDataNoDetails                     System.Object

I also found the type of the returned object is PSEventDataNoDetails (which can be seen above), and I found that it has a Caller property.

cormacpayne avatar Oct 20 '17 20:10 cormacpayne

Oh, I got it wrong then. I thought you meant that data was available for Caller property but it was not being displayed in the output.

karun-r avatar Oct 20 '17 20:10 karun-r

@karun-r ah sorry, I meant that the property is still available to access, but it is not being populated with any value

cormacpayne avatar Oct 20 '17 20:10 cormacpayne

No problem, and on further troubleshooting, I observed that this is happening only for events that have Authorization.Action set to 'Microsoft.Compute/VirtualMachines/write'. For delete events, I am able to see the value in caller property. That is,

Caller value is null. $ActivityLog | Where-Object {$_.Authorization.Action -eq 'Microsoft.Compute/VirtualMachines/write'}

Caller value is not null. $ActivityLog | Where-Object {$_.Authorization.Action -eq 'Microsoft.Compute/VirtualMachines/delete'}

Donno if this helps.

karun-r avatar Oct 20 '17 21:10 karun-r

Is there any update on this issue ? Status is still same even after a month. This is happening only for some kind of events as I stated.

karun-r avatar Nov 21 '17 00:11 karun-r

@gucalder ping

cormacpayne avatar Jul 06 '18 19:07 cormacpayne

You may have to weed out service health events by adding | Where {$_.Category -ne 'ServiceHealth'} as the have no Caller

Sergmis avatar Jul 20 '18 21:07 Sergmis

Not every record in Activity Logs will have caller property. Typically the caller property is only available for records in Activity Logs which are generated in category 'Administrative' by Azure Resource Manager. Additionally, the caller property is a virtual property which is computed from the information in the Claims property (emailaddress/upn/spn) of the record. If you are seeing missing data in the Claims property for specific records in the Activity Logs, the best way to follow up is to open a support ticket and we can follow up with the appropriate Azure team.

asheniam avatar Jan 15 '20 00:01 asheniam