gpt4 book ai didi

c# - 如何设置 Azure Functions 的 MaxReceivedMessageSize

转载 作者:太空狗 更新时间:2023-10-29 22:01:59 26 4
gpt4 key购买 nike

我正在创建一个 Azure 函数,它将接收 POSTed 文件并对其进行处理。我已经完成了基本设置,可以成功发布一个小文件。每当我发布一个大文件时,我都会收到以下错误消息。

A ScriptHost error has occurred
Exception while executing function: Functions.HttpTriggerCSharp. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'request'. System.ServiceModel: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
Exception while executing function: Functions.HttpTriggerCSharp
Executed: 'Functions.HttpTriggerCSharp' (Failed)
Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '5fc0eaa2-0159-4185-93e4-57a4b2d4bb7f'

我无法找到任何有关在何处设置该属性的 Azure Functions 文档。是否可以增加 Azure Functions 的最大消息大小?

编辑

function.json

{
"disabled": false,
"bindings": [
{
"name": "request",
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"methods": [ "GET", "POST" ],
"route": "test"
},
{
"name": "response",
"type": "http",
"direction": "out"
}
]
}

run.csx

using System.Net;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage request, TraceWriter log)
{
log.Info($"C# HTTP trigger function processed a request. RequestUri={request.RequestUri}");

// parse query parameter
string name = request.GetQueryNameValuePairs()
.FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
.Value;

return name == null
? request.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
: request.CreateResponse(HttpStatusCode.OK, "Hello " + test.Value);
}

最佳答案

只是一个想法 - 您是否会考虑将文件内容发布为类似 azure Blob 的内容,然后将链接发布到文件(可以受基于计时器的链接保护),以便让您的 azure 函数从那里获取它?将大文件上传与主要发布请求分开是很常见的做法,该请求未针对处理大文件进行优化。

关于c# - 如何设置 Azure Functions 的 MaxReceivedMessageSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41189588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com