我创建了 Azure Function Api 和这个返回随机密码的 API。我正在执行循环 4000 次并调用此 API,但此 API 仅返回 256 个随机密码并保持为空...
我已经在本地执行了相同的 API 代码,它在没有函数 API 的情况下工作正常,所以看起来 Azure Functions 有一些限制。
有人可以建议他们是否遇到同样的问题,或者如何扩大规模以获得 4000 多条记录?
请建议...
这就是我的 API
public static class HashPwd
{
[FunctionName("HashPwd")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = RandomPassword(name);
string responseMessage = string.IsNullOrEmpty(name)
? "TempPassword"
: $"{name}";
return new OkObjectResult(responseMessage);
}
private static string RandomPassword(string name)
{
int lengthOfPassword = 8;
string encyPassword = "";
string valid = "abcdefghijklmnozABCDEFGHIJKLMNOZ1234567890!@#$%&";
StringBuilder orgPasswordR = new StringBuilder();
Random random = new Random();
while (0 < lengthOfPassword--)
{
orgPasswordR.Append(valid[random.Next(valid.Length)]);
}
string orgPassword = orgPasswordR.ToString();
return orgPassword;
}