问题描述
我无法在本地运行Cosmos DB Change Feed触发器功能。
public static class NotificationChangeFeed
{
[FunctionName("NotificationChangeFeed")]
public static async Task Run([CosmosDBTrigger(
databaseName: "FleetHubNotifications",collectionName: "Notification",ConnectionStringSetting = "CosmosDBConnection",CreateLeaseCollectionIfNotExists = true,LeaseCollectionName = "leases")]IReadOnlyList<Document> input,[Inject] ILoggingService loggingService,[Inject] IEmailProcessor emailProcessor)
{
var logger = new Logger(loggingService);
try
{
if (input != null && input.Count > 0)
{
foreach (Document document in input)
{
string requestBody = document.ToString();
var notification = requestBody.AsPoco<Notification>();
var result = await emailProcessor.HandleEmailAsync(notification,logger);
if (result)
{
logger.Info($"Email Notification sent successfully for file name: {document.Id}");
}
else
{
logger.Warning($"Unable to process document for Email Notification for file with name: {document.Id}");
}
}
}
}
catch (Exception ex)
{
logger.Error($"Unable to process Documents for Email Notification for Files: {input?.Count}",ex,nameof(NotificationChangeFeed));
throw;
}
}
}
local.settings.json
{
"IsEncrypted": "false","Values": {
"AzureWebJobsstorage": "UseDevelopmentStorage=true","AzureWebJobsDashboard ": "UseDevelopmentStorage=true","FUNCTIONS_WORKER_RUNTIME": "dotnet","CosmosDbId": "FleetHubNotifications",//Localhost
"CosmoDbAuthKey": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==","CosmoDbEndpoint": "https://localhost:8081/","CosmosDBConnection": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",}
}
当我按F5键时,它卡在了控制台窗口中。(如下面的屏幕截图所示)
错误:连接ECONNREFUSED 127.0.0.1:7071
有什么想法吗?