Возникла проблема при создании Cosmos Db с использованием пакета SDK для .NET core.C#

Место общения программистов C#
Anonymous
Возникла проблема при создании Cosmos Db с использованием пакета SDK для .NET core.

Сообщение Anonymous »

Код успешно создал контейнер, который теперь доступен для использования. Однако при попытке создать базу данных происходит бесконечный цикл.
var name = "cosmosdb_emulator";
var exposedPort = 8083; // Port exposed by the container
var ContainerCosmosServicePort = 8081; // Port used by the Cosmos service within the container

try
{
var containerService = new Builder()
.UseContainer()
.WithName(name)
.UseImage($"mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator")
.ReuseIfExists()
.ExposePort(exposedPort, ContainerCosmosServicePort)
// .WaitForMessageInLog("Cosmos service is successfully listening")
.Build();

containerService.Start();
Console.WriteLine($"Container {name} started successfully.");

var _cosmosdbConnectionString = "AccountEndpoint=https://localhost:8083/;AccountKey=C2y6 ... 67XIw/Jw==";

CosmosClientOptions options = new()
{
HttpClientFactory = () => new HttpClient(new HttpClientHandler()
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
})
};
// Initialize Cosmos DB client
CosmosClient client = new CosmosClient(_cosmosdbConnectionString, clientOptions: options);

// Check if the database exists; if not, create it
DatabaseResponse databaseResponse = await client.CreateDatabaseIfNotExistsAsync("abc");


Подробнее здесь: https://stackoverflow.com/questions/781 ... t-core-sdk

Вернуться в «C#»