簡體   English   中英

無法在本地運行 Cosmos DB Change Feed Trigger Azure Function

[英]Not able to run Cosmos DB Change Feed Trigger Azure Function locally

我無法在本地運行 Cosmos DB Change Feed Trigger 功能。

Cosmos DB 更改源觸發器 Azure 功能:

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;
            }
        }
    }

本地設置.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 時,它卡在控制台窗口中。(如下面的屏幕截圖所示)

也不能調用 http 觸發函數。 調用時出現以下錯誤:

錯誤:連接 ECONNREFUSED 127.0.0.1:7071

有什么想法嗎?

在此處輸入圖片說明

是的,在那部分您只能獲得 http 函數的端點。 其他函數也被初始化並等待任何類型的事件。 你可以在這里看到它:找到以下函數,4 個 http 觸發器,另外 2 個是 blob 觸發器。

在此處輸入圖片說明

如果要調試 NotificationChangeFeed 函數,則必須在數據庫上創建一個新文檔,並使該函數運行並等待該事件。 您將在控制台中看到遙測數據,您可以調試該功能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM