Я получил сообщение об ошибке при выделении моей функции Azure, это связано с ограничением в 300 соединений: https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#numerical-sandbox-limits
Решение состоит в том, чтобы использовать статических клиентов, поэтому, когда функция запрашивается несколько раз, одинклиент всегда используется, а не новый клиент каждый раз.Я оцепенел на C # и программировании, поэтому я даже не понимаю, что делать.
Можете ли вы помочь мне реализовать то, что предлагается здесь .Это мой код:
[FunctionName("Search")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req,
TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
// the person objects will be free-form in structure
List<dynamic> results = new List<dynamic>();
// open the client's connection
using (DocumentClient client = new DocumentClient(
new Uri(endpoint),
authKey,
new ConnectionPolicy
{
ConnectionMode = ConnectionMode.Direct,
ConnectionProtocol = Protocol.Tcp
}))
{
// get a reference to the database the console app created
Database database = await client.CreateDatabaseIfNotExistsAsync(
new Database
{
Id = "cloudcasegraph"
});
// get an instance of the database's graph
DocumentCollection graph = await client.CreateDocumentCollectionIfNotExistsAsync(
UriFactory.CreateDatabaseUri("cloudcasegraph"),
new DocumentCollection { Id = "poc-graph1" },
new RequestOptions { OfferThroughput = 400 }
);
// Get the gremlinquery from the headers
IEnumerable<string> headerValues = req.Headers.GetValues("gremlinquery");
var gremlinquery = headerValues.FirstOrDefault();
//Make the query against the graph
IDocumentQuery<dynamic> query = client.CreateGremlinQuery<dynamic>(graph, string.Format("{0}", gremlinquery));
// iterate over all the results and add them to the list
while (query.HasMoreResults)
foreach (dynamic result in await query.ExecuteNextAsync())
results.Add(result);
}
// return the list with an OK response
return req.CreateResponse<List<dynamic>>(HttpStatusCode.OK, results);
}
}