MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.21k stars 21.38k forks source link

“TooMuchData” error during graphical runbook run #21758

Closed imeya closed 5 years ago

imeya commented 5 years ago

our customer encountered an issue, his graphical runbook which outputs a large json file about 5MB, and cause an error says "TooMuchData". Is there a limit how much data can be returned by runbooks to output stream? if has, how to change it?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Karishma-Tiwari-MSFT commented 5 years ago

Thanks for the question. We are currently investigating and will update you shortly.

georgewallace commented 5 years ago

@imeya There are limits to the output stream. But the error you are stating sounds like it is an error being returned because of too much data being returned in Activity-Level Tracing. Can you confirm if you are using Activity Level Tracing? There are other limits that apply to this tracing data so want to figure out where you are hitting it so we can provide the correct answer and ensure our documents are up to date.

image

artisticcheese commented 5 years ago

So design is. There is graphical runbook which in turns calls powershell runbook which returns JSON file as ouput. Below is output which is seen in graphical runbook when detailed activity-level tracing is enabled.

GraphTrace:{ Activity:"Get-VMs",
Event:"ActivityOutput",          Time:"2019-01-08T01:41:26.0190972Z",
Values:{ Status:"TooMuchData" }
}

Below activity which is being called from graphical runbook


# Retrieve all Public IPs 
$AllPublicIPs = Get-AzureRMPublicIPaddress 
# Retrieve all Virtual Networks 
$vnetall = Get-AzureRMVirtualNetwork 
# Retrieve all Network Interfaces 
$nicall = Get-AzureRmNetworkInterface 
# Retrieve all ARM Virtual Machines 
$AllVMs = Get-AzureRMVM | Sort-object location, resourcegroupname, name 
$StatusForAllVms = Get-azureRmVM -Status
#TESTComment2

# Get VM sizes supported by Azure in the given RG. Call this only once.
if ($AllVMs -ne $null) {
    # Retrieve all available Virtual Machine Sizes 
    Write-Verbose "5- Retrieving all available Virtual Machines Sizes..." 
    $AllVMsSize = Get-AzureRmVMSize -Location "West US"  #  Using West US and South Central US and East US 2 as those 2 locations are usually the ones with all and newer VM sizes 
    $AllVMsSizeSCU = Get-AzureRmVMSize -Location "South Central US" 
    foreach ($VMsSizeSCU in $AllVMsSizeSCU) {
        if ($AllVMsSize.Name -notcontains $VMsSizeSCU.Name) { $AllVMsSize += $VMsSizeSCU } 
    } 
    $AllVMsSizeEU2s = Get-AzureRmVMSize -Location "East US 2"
    foreach ($VMsSizeEU2 in $AllVMsSizeEU2s) { 
        if ($AllVMsSize.Name -notcontains $VMsSizeEU2.Name) { $AllVMsSize += $VMsSizeEU2 } 
    } 

}
$AzureVMs = @() 
foreach ($CurrentVM in $AllVMs) {
    $azureVM = [PSCustomObject]@{}
    $azureVM | add-Member -MemberType NoteProperty -Name "Name" -Value $currentVM
    $azureVM | Add-Member -MemberType NoteProperty -Name "VMName" -Value $CurrentVM.Name
    $azureVM | Add-Member -MemberType NoteProperty -Name "Location" -Value $CurrentVM.Location
    $azureVM | Add-Member -MemberType NoteProperty -Name "ResourceGroup" -Value $CurrentVM.ResourceGroupName
    $AzureVM | Add-Member -MemberType NoteProperty -Name "OSType" -Value $CurrentVM.StorageProfile.OsDisk.OsType.ToString()
    $azureVM | add-Member -MemberType NoteProperty -Name "PowerState" -Value $StatusForAllVms.Where{$_.Name -eq $CurrentVM.Name}.PowerState
    $azureVM | Add-Member -MemberType NoteProperty -Name "BootDiagnostics" -Value $CurrentVM.DiagnosticsProfile.BootDiagnostics.Enabled
    $azureVM | Add-Member -MemberType NoteProperty -Name "OSDiskSizeGB" -Value $CurrentVM.StorageProfile.OsDisk.DiskSizeGB
    $azureVM | Add-Member -MemberType NoteProperty -Name "NumberOfDataDisks" -Value $CurrentVM.StorageProfile.DataDisks.Count
    $azureVM | Add-Member -MemberType NoteProperty -Name "Offer" -Value $CurrentVM.StorageProfile.ImageReference.Offer
    $azureVM | Add-Member -MemberType NoteProperty -Name "Publisher" -Value $CurrentVM.StorageProfile.ImageReference.Publisher
    $azureVM | Add-Member -MemberType NoteProperty -Name "VMSize" -Value $CurrentVM.HardwareProfile.VmSize
    if ($azureVM.PowerState -eq "VM running") {
        $azureVM | Add-Member -MemberType NoteProperty -Name "DataDisksSize" -Value (($currentVM.StorageProfile.DataDisks | ForEach-Object {$_.DiskSizeGB}) -join "|")
    }
    #region NICs
    $privateIPs = @()
    $publicIPs = @()
    $vnetName = ""
    foreach ($currentNic in $CurrentVM.NetworkProfile.networkInterfaces) {
        $nicinfo = $nicall.Where{$_.ID -eq $currentNic.Id}
        $vnetName = $vnetall.where{$_.Subnets.ID -eq $nicInfo.IpConfigurations.Subnet.ID}.Name
        $subnet = ($nicInfo.IpConfigurations.Subnet.ID -split "/")[-1]
        $nicInfo.IpConfigurations.Foreach{
            $privateIPs += $_.PrivateIPAddress;
            if ($null -ne $_.PublicIpAddress) {
                $ipID = $_.PublicIpAddressText | convertFrom-Json | Select-Object ID
                $publicIPs += $AllPublicIPs.Where{$_.ID -eq $ipID.ID}.IpAddress
            }
        }
    }
    #endregion
    $azureVM | Add-Member -MemberType NoteProperty -Name "VnetName" -Value $vnetName
    $azureVM | Add-Member -MemberType NoteProperty -Name "Subnet" -Value $subnet
    $azureVM | Add-Member -MemberType NoteProperty -Name "privateIPs" -Value ($privateIPs -join ",")
    $azureVM | Add-Member -MemberType NoteProperty -Name "publicIPs" -Value ($publicIPs -join ",")

    if ($null -ne $CurrentVM.OsDisk.vhd ) {$azureVM | add-Member -MemberType NoteProperty -Name "unmanagedDisk" -Value $CurrentVM.OsDisk.vhd.Uri.Split("/")[2].Split(".")[0]}
    if ($null -ne $CurrentVM.AvailabilitySetReference) {$azureVM | add-Member -MemberType NoteProperty -Name "AvailabilitySet" -Value $CurrentVM.AvailabilitySetReference.Id.split("/")[-1]}
    $tags = $CurrentVM.tags
    $tagkeys = $tags.Keys
    if ($tagkeys -match "Name") {
        $azureVM | Add-Member -MemberType NoteProperty -Name "NameTag" -Value $CurrentVM.tags["Name"]
    }
    if ($tagkeys -match "Owner") {
        $azureVM | Add-Member -MemberType NoteProperty -Name "OwnerTag" -Value $CurrentVM.tags["Owner"]
    }
    if ($tagkeys -match "Environment") {
        $azureVM | Add-Member -MemberType NoteProperty -Name "EnvironmentTag" -Value $CurrentVM.tags["Environment"]
    }
    if ($tagkeys -match "Function") {
        $azureVM | Add-Member -MemberType NoteProperty -Name "FunctionTag" -Value $CurrentVM.tags["Function"]
    }
    $azureVM | Add-Member -MemberType NoteProperty -Name "VMCores" -Value $AllVMsSize.Where{$_.Name -eq $CurrentVM.HardwareProfile.VmSize}.NumberOfCores
    $azureVM | Add-Member -MemberType NoteProperty -Name "VMmemory" -Value (($AllVMsSize.Where{$_.Name -eq $CurrentVM.HardwareProfile.VmSize}.MemoryInMB) / 1024)
    $AzureVMs += $azureVM
}

$AzureVMs | ConvertTo-Json -Depth 50
artisticcheese commented 5 years ago

Specifically addition of $azureVM | add-Member -MemberType NoteProperty -Name "Name" -Value $currentVM is what brings this behavior since it greatly inflates returned JSON file (to aroun 5 MB in my case)

artisticcheese commented 5 years ago

I had to enable detailed logging since job otherwise just fails 3 times and I can not find out why. There is no additional information available

georgewallace commented 5 years ago

@artisticcheese Thanks for clearing that up. So as far as your runbook failing 3 times this is normally due to Fair Share. We also have a troubleshooting section on runbooks running 3 times and failing that may be of use as well. It may be that you are hitting the memory limit at that is why it is failing. Since the data stored in $currentVM is easily accessible at runtime, it may be a good idea to not store that in the Json output and call it when it is needed, perhaps just store the resourceid and use Get-AzureRmResource -ResourceId <myresourceid> to track it. It is hard to say what is causing you to hit the fair share limit, support is able to determine this but unfortunately I can not.

femsulu commented 5 years ago

@imeya Here are the steps to raise a support tickets with Azure technical support. If you already have a support plan. If you don't, please send mail to AzCommunity@microsoft.com with your subscription ID and a link to this Github thread (for context) and we will assist you with engaging Azure technical support.