【发布时间】:2018-03-29 09:55:42
【问题描述】:
我创建了一个Azure Functions project and am testing it locally。下面是我创建云队列的代码。然后它添加从我的 CarComponent 返回的 id。
[FunctionName("CarDiscovery")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
var connectionString = "UseDevelopmentStorage=true";
// Parse the connection string and return a reference to the storage account.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
// Retrieve a reference to a container.
CloudQueue queue = queueClient.GetQueueReference("discovery-queue");
// Create the queue if it doesn't already exist
queue.CreateIfNotExists();
CarComponent cars = new CarComponent();
var carList = cars.GetActiveCars();
foreach (var car in carList)
{
byte[] toAdd = BitConverter.GetBytes(car.Id);
CloudQueueMessage message = new CloudQueueMessage(toAdd); // <-- Put the ID of each metro in the message
queue.AddMessage(message);
}
}
当我使用 azure 存储模拟器启动该功能时,它运行成功。
我想创建另一个使用队列触发器运行的 azure 函数,我可以在本地进行测试。
(1) 我在哪里可以查看当前已添加到开发存储中的消息?
(2) 使用队列触发器创建 Azure 函数时,我应该指定什么作为连接? (见下文)
【问题讨论】:
-
这里有一些对你有用的东西 - docs.microsoft.com/en-us/azure/azure-functions/…
标签: c# azure azure-functions