Tôi đang làm việc để tạo ra một hàm Azure sẽ lấy trong một tệp POST và xử lý nó. Tôi đã thiết lập cơ bản và tôi có thể POST thành công một tệp nhỏ. Bất cứ khi nào tôi đăng một tập tin lớn, tôi nhận được thông báo lỗi sau.Cách đặt MaxReceivedMessageSize cho các hàm Azure
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'
Tôi chưa thể tìm thấy bất kỳ tài liệu Chức năng Azure nào về vị trí đặt thuộc tính đó. Có thể tăng kích thước tin nhắn tối đa cho các chức năng Azure không?
Sửa
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);
}
Bạn có muốn chia sẻ mã chức năng và chức năng của bạn.json như thế nào không? Điều này trông giống như một thông báo lỗi WCF, mà tôi sẽ không mong đợi từ một cuộc gọi HttpTrigger, vì vậy tôi tò mò để cố gắng để tái sản xuất nó và xem chúng tôi có thể giúp đỡ. – brettsam
Đã mở [issue] (https://github.com/Azure/azure-webjobs-sdk-script/issues/1063) để theo dõi lỗi tương tự. Nó sẽ giúp nếu bạn có thể chia sẻ mã của bạn ở đây hoặc trên github –
Tôi đã thêm nội dung của tệp function.json và run.csx của tôi. Chúng không thay đổi nhiều từ đĩa nồi hơi vì tôi đã thử nghiệm với các chức năng Azure khi tôi gặp phải vấn đề này. – jdehlin