首页 > 解决方案 > Azure Functions 内存不足异常

问题描述

我有一个 Azure Functions Powershell 核心,如下所示:

# Input bindings are passed in via param block.
param([byte[]] $InputBlob, $TriggerMetadata)

# Write out the blob name and size to the information log.
Write-Host "PowerShell Blob trigger function Processed blob! Name: $($TriggerMetadata.Name) Size: $($InputBlob.Length) bytes  Uri: $($TriggerMetadata.Uri)"

通过使用 Blob 触发器,我想使用 Powershell 从 Azure Blob 读取 VDH OS 映像并将它们转换为托管磁盘。图像大小为 30GB。当函数被触发时,我得到下面的System.OutOfMemoryException

2020-09-07T09:52:44.704 [Error] Executed 'Functions.BlobTrigger1' (Failed, Id=93b00718-9941-4379-abd0-348137cdcff2, Duration=56449ms)Exception of type 'System.OutOfMemoryException' was thrown.
2020-09-07T09:52:45.061 [Information] Stopping JobHost

我增加了应用计划以获得 14GB 的内存,但我遇到了同样的内存异常。

当我直接从Cloud Shell执行此操作时,我获得了成功,但我的主要目标是使用Blob Trigger自动化脚本。

你有什么建议吗?

标签: azurepowershellazure-functionsout-of-memoryazure-blob-storage

解决方案


检查 Function App 的平台配置:

功能 -> 配置 -> 常规设置 -> 平台

在此处输入图像描述

32 位将有更少的私有字节,即使实例有更多的容量,它也会遇到内存不足的异常。

如果是这种情况,建议您升级到64 位


推荐阅读