Я создаю приложение-функцию Azure для доступа к хранилищу очередей Azure (триггер планировщика), получения сообщений и отправки электронных писем с использованием SendGrid.
Я потратил много времени на отладку и сканирование StackOverFlow, но все ещеполучил то же сообщение об ошибке.
Вот сообщение об ошибке.
[Ошибка] Исключение при выполнении функции: Functions.ScheduledMailCSharpHobby.mscorlib: Исключение было сгенерировано целью вызова.Microsoft.WindowsAzure.Storage: параметры должны иметь форму «имя = значение».
ФАЙЛ: run.csx
#r "SendGrid"
#r "Microsoft.WindowsAzure.Storage"
using System;
using SendGrid.Helpers.Mail;
using Microsoft.Azure;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Queue;
public static Mail Run(TimerInfo myTimer, TraceWriter log)
{
var today = DateTime.Today.ToShortDateString();
log.Info($"Generating daily report for {today} at {DateTime.Now}");
Mail message = new Mail()
{
Subject = $"Daily Report for {today}"
};
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("serverlessbdbxxxxxxx");
// Get queue... create if does not exist.
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("memberqueue");
// Peek at the next message
CloudQueueMessage peekedMessage = queue.PeekMessage();
// Display message.
log.Info(peekedMessage.AsString);
var mail_content = peekedMessage.AsString;
Content content = new Content
{
Type = "text/plain",
Value = $"Hi! {mail_content}"
};
message.AddContent(content);
return message;
}
ФАЙЛ: function.json
{
"bindings": [
{
"type": "timerTrigger",
"name": "myTimer",
"schedule": "0 0 17 * * *",
"direction": "in"
},
{
"type": "sendGrid",
"name": "$return",
"direction": "out",
"apiKey": "AzureWebJobsSendGridApiKey",
"from": "Azure Functions <samples@functions.com>",
"to": "xxxx@gmail.com"
}
]
}