У меня есть лазурная функция таймера, которая вызывает хранимую процедуру, и процедура возвращает набор записей. Каков наилучший способ получить значение из набора записей и поместить его в очередь, используя привязку вывода к сигнатуре функции таймера.
Мне нужно иметь возможность просматривать содержимое таблицы и помещать одно значение столбца в очередь. Если в наборе записей 50 записей, в очереди будет 50 записей.
Вот мой код
public static void FieldDevicePollingStatusDispatch_Run ([TimerTrigger("%ScheduleDispatch%")]TimerInfo myTimer,
[Queue("%DispatchQueueName%", Connection = "AVStorageAccessKey")] out string msg, //output binding
ILogger log)
{
oConnect.Open();
DataTable oDataTable = new DataTable();
SqlCommand objCommand = new SqlCommand("CallProc", oConnect);
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.Connection = oConnect;
SqlDataAdapter oDataAdapter = new SqlDataAdapter(objCommand);
oDataAdapter.Fill(oDataTable);
msg = // Content from the table, need one column from table.
}
Вы можете использовать return
атрибут:
[StorageAccount("AzureWebJobsStorage")]
public static class QueueFunctions
{
[FunctionName("QueueOutput")]
[return: Queue("myqueue-items")]
public static string QueueOutput([HttpTrigger] dynamic input, ILogger log)
{
log.LogInformation($"C# function processed: {input.Text}");
return input.Text;
}
}