我正在 Docker 容器中运行本地 Cosmos DB。我已经关注了这个doc。
我正在 Visual Studio Code 中运行 Azure Function。我还使用此方法从 Docker 导入了 Cosmos DB 的 SSL 证书。我运行的是 Windows 11 操作系统。
但是我不断收到此错误:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.MyCoFunc'. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cannot create container information for products in database cosmicworks4 with lease leases in database cosmicworks4 : The SSL connection could not be established, see inner exception. System.Net.Http: The SSL connection could not be established, see inner exception. System.Private.CoreLib: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot.
[2023-12-23T16:54:16.993Z] Error indexing method 'Functions.MyCoFunc'
using System;
using System.Collections.Generic;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace Function_CosmosDB_Trigger
{
public class MyCoFunc
{
private readonly ILogger _logger;
public MyCoFunc(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<MyCoFunc>();
}
[Function("MyCoFunc")]
public void Run([CosmosDBTrigger(
databaseName: "cosmicworks4",
containerName: "products",
Connection = "DBConnectionString",
LeaseContainerName = "leases",
CreateLeaseContainerIfNotExists = true)] IReadOnlyList<MyDocument> input)
{
if (input != null && input.Count > 0)
{
_logger.LogInformation("Documents modified: " + input.Count);
_logger.LogInformation("First document Id: " + input[0].id);
}
}
}
public class MyDocument
{
public string id { get; set; }
public string Text { get; set; }
public int Number { get; set; }
public bool Boolean { get; set; }
}
}
出了什么问题?
谢谢
即使最初我也遇到了同样的错误。
我执行了以下步骤来解决此错误 -