Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.63k stars 5.08k forks source link

[Question] while getting acivity log via rest api, it returned unexpected turkey language value #29962

Open kmin1223 opened 2 months ago

kmin1223 commented 2 months ago

API Spec link

https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/rest-activity-log

API Spec version

2015-04-01

Question/Query

My customer is using rest api to get activity logs in powershell.

Sypmtom is that returned value had below strange operation name in Turkey.

Microsoft.Compute - mw-p-1020033 : Etiket yaz (KST: 07/24/2024 07:51:28 ) resourceType: Microsoft.Compute resourceName: mw-p-1020033 operation: Etiket yaz status_result: Succeeded message:

This is not reproducing now, but they want to know why this happened.

Below is the powershell script they are using and below operationName.localizedValue was the trouble part. $operation = $avstatus_result.operationName.localizedValue`

Please help advise about this symptom.

`$datetime_min_ago = '2024-07-23T22:40:00Z'

$datetime_current = '2024-07-23T23:00:00Z'

$datetime_min_ago = [DateTime]::UtcNow.AddMinutes(-5).ToString('u').Replace(' ','T')

$datetime_current = [DateTime]::UtcNow.ToString('u').Replace(' ','T')

Get-AzSubscription

Set-AzContext -SubscriptionId $subscriptionId

 $resource_Groupname = "RG-TFDEUS-PRD"

$avstatus_Uri =  https://management.azure.com/subscriptions/$subscriptionId/providers/Microsoft.Insights/eventtypes/management/values?api-version=2015-04-01&`$filter=eventTimestamp ge $datetime_min_ago and eventTimestamp le $datetime_current and resourceGroupName eq $resource_Groupname

$avstatus = RestMethod $avstatus_Uri

$avstatus_results = $avstatus.value | Where-object {$_.resourceId -match "Microsoft.Compute" -OR $_.resourceId -match "Microsoft.Cache" -OR $_.resourceId -match "Microsoft.Sql" -OR $_.resourceId -match "Microsoft.Network"}

$includeSet = @{}

$status_value=""

$arraycount=0

$count=0

Set-TimeZone -Id "UTC"

    if($avstatus_results)

    {

        foreach ($avstatus_result in $avstatus_results){

            $status_value = 1

            $kstTimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById('Korea Standard Time')

            $eventTimestamp_utc      = [DateTime]::SpecifyKind($avstatus_result.eventTimestamp,[DateTimeKind]::utc)

            $submissionTimestamp_utc = [DateTime]::SpecifyKind($avstatus_result.submissionTimestamp,[DateTimeKind]::utc)

            $eventTimestamp_kst = [System.TimeZoneInfo]::ConvertTime($eventTimestamp_utc, $kstTimeZone)               

            $submissionTimestamp_kst = [System.TimeZoneInfo]::ConvertTime($submissionTimestamp_utc, $kstTimeZone)               

            $subscriptionId          = $avstatus_result.subscriptionId

            $caller                  = $avstatus_result.caller

            $resourceName            = $avstatus_result.resourceId.split("/") | Select-Object -Last 1

            $resourceType            = $avstatus_result.resourceId.split("/") | Select-Object -Last 3 | Select-Object -First 1

            **$operation               = $avstatus_result.operationName.localizedValue`**

Environment

powershell

v-jiaodi commented 2 months ago

@akshitgoyal Please help take a look, thanks.