kmanjt
kmanjt
CC#
Created by kmanjt on 6/22/2024 in #help
Azure DevOps Pipelines: Environment Variables Not Available in dotnet test Command
Please note, I require the dotnet test to be inside of the AzureCLI@2 task, to make use of the new AzurePipelinesCredential from the Azure Identity SDK
3 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
The exception is actually being thrown here in my Program.cs:
clientsBuilder.AddClient<CosmosClient, CosmosClientOptions>(options =>
{
options.Serializer = new CosmosJsonSerializer();
options.ApplicationRegion = cosmosConfig.ApplicationRegion;
return new CosmosClient(cosmosConfig.ConnectionString, options);
})
clientsBuilder.AddClient<CosmosClient, CosmosClientOptions>(options =>
{
options.Serializer = new CosmosJsonSerializer();
options.ApplicationRegion = cosmosConfig.ApplicationRegion;
return new CosmosClient(cosmosConfig.ConnectionString, options);
})
29 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
Not to do with Testcontainers itself
29 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
Ok so the weird thing is, this seems to be an issue with how I am instantiating my cosmos client
29 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
bump still no success 😦
29 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
sorry I am confused how that relates here, here is my Program.cs setup for CosmosDB:
builder.Services.AddSingleton<CosmosClient>(cosmosClient => new CosmosClient(cosmosConfig.ConnectionString, new CosmosClientOptions()
{
ApplicationRegion = cosmosConfig.ApplicationRegion,
}));

builder.Services.AddAzureClients(clientsBuilder =>
{
clientsBuilder.AddClient<CosmosClient, CosmosClientOptions>(options =>
{
options.Serializer = new CosmosJsonSerializer();
options.ApplicationRegion = cosmosConfig.ApplicationRegion;
return new CosmosClient(cosmosConfig.ConnectionString, options);
})
.WithName(cosmosConfig.CosmosDbClientName);
});
builder.Services.AddSingleton<CosmosClient>(cosmosClient => new CosmosClient(cosmosConfig.ConnectionString, new CosmosClientOptions()
{
ApplicationRegion = cosmosConfig.ApplicationRegion,
}));

builder.Services.AddAzureClients(clientsBuilder =>
{
clientsBuilder.AddClient<CosmosClient, CosmosClientOptions>(options =>
{
options.Serializer = new CosmosJsonSerializer();
options.ApplicationRegion = cosmosConfig.ApplicationRegion;
return new CosmosClient(cosmosConfig.ConnectionString, options);
})
.WithName(cosmosConfig.CosmosDbClientName);
});
29 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
Mapped public port for Cosmos DB: 56685 Connection string generated: AccountEndpoint=https://127.0.0.1:56685/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
29 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
I have changed it to this, which is still not working (and containers are not disposing properly either):
public abstract class IntegrationTest : IDisposable
{
protected readonly HttpClient TestClient;
private readonly CosmosDbContainer _cosmosDbContainer = new CosmosDbBuilder()
.WithPortBinding(0, 8081)
.Build();

protected IntegrationTest()
{
TestClient = InitializeClient().GetAwaiter().GetResult();
}

public async Task InitializeAsync()
{
await _cosmosDbContainer.StartAsync();
Console.WriteLine($"Mapped public port for Cosmos DB: {_cosmosDbContainer.GetMappedPublicPort(8081)}");
}

public async Task DisposeAsync()
{
await _cosmosDbContainer.DisposeAsync().AsTask();
}

private async Task<HttpClient> InitializeClient()
{
await InitializeAsync();
var appFactory = new WebApplicationFactory<Program>()
.WithWebHostBuilder(builder =>
{
builder.ConfigureServices(services =>
{
var connectionString = _cosmosDbContainer.GetConnectionString();
Console.WriteLine($"Connection string generated: {connectionString}");

var cosmosOptions = new CosmosClientOptions
{
Serializer = new CosmosJsonSerializer(),
ConnectionMode = ConnectionMode.Gateway,
HttpClientFactory = () => _cosmosDbContainer.HttpClient
};

services.RemoveAll(typeof(CosmosClient));
services.AddSingleton(new CosmosClient(connectionString, cosmosOptions));
});

builder.UseEnvironment("Development");
});

return appFactory.CreateClient();
}


public void Dispose()
{
TestClient.Dispose();
DisposeAsync().GetAwaiter().GetResult();
}
public abstract class IntegrationTest : IDisposable
{
protected readonly HttpClient TestClient;
private readonly CosmosDbContainer _cosmosDbContainer = new CosmosDbBuilder()
.WithPortBinding(0, 8081)
.Build();

protected IntegrationTest()
{
TestClient = InitializeClient().GetAwaiter().GetResult();
}

public async Task InitializeAsync()
{
await _cosmosDbContainer.StartAsync();
Console.WriteLine($"Mapped public port for Cosmos DB: {_cosmosDbContainer.GetMappedPublicPort(8081)}");
}

public async Task DisposeAsync()
{
await _cosmosDbContainer.DisposeAsync().AsTask();
}

private async Task<HttpClient> InitializeClient()
{
await InitializeAsync();
var appFactory = new WebApplicationFactory<Program>()
.WithWebHostBuilder(builder =>
{
builder.ConfigureServices(services =>
{
var connectionString = _cosmosDbContainer.GetConnectionString();
Console.WriteLine($"Connection string generated: {connectionString}");

var cosmosOptions = new CosmosClientOptions
{
Serializer = new CosmosJsonSerializer(),
ConnectionMode = ConnectionMode.Gateway,
HttpClientFactory = () => _cosmosDbContainer.HttpClient
};

services.RemoveAll(typeof(CosmosClient));
services.AddSingleton(new CosmosClient(connectionString, cosmosOptions));
});

builder.UseEnvironment("Development");
});

return appFactory.CreateClient();
}


public void Dispose()
{
TestClient.Dispose();
DisposeAsync().GetAwaiter().GetResult();
}
29 replies
CC#
Created by kmanjt on 5/13/2024 in #help
Testcontainers CosmosDB / WebApplication Factory ConnectionString Not Working
29 replies
CC#
Created by kmanjt on 5/9/2024 in #help
NetArchTests Not Detecting Project References
Bump
2 replies
CC#
Created by kmanjt on 5/8/2024 in #help
Resolving External Components with Nested Components in NSwag for OpenAPI specs
Bump
2 replies
CC#
Created by kmanjt on 2/8/2024 in #help
Programmatically issue API Management Subscription Keys
yes sorry @BallBuster McCheese - i have updated the description thank you
6 replies
CC#
Created by kmanjt on 2/7/2024 in #help
situation where the response to an InfluxDB query can be huge (10+ MB easily)
thanks for the help anyhow it was reassuring
22 replies
CC#
Created by kmanjt on 2/7/2024 in #help
situation where the response to an InfluxDB query can be huge (10+ MB easily)
its a very disgustingly large object
22 replies
CC#
Created by kmanjt on 2/7/2024 in #help
situation where the response to an InfluxDB query can be huge (10+ MB easily)
it seems to be native memory
22 replies
CC#
Created by kmanjt on 2/7/2024 in #help
situation where the response to an InfluxDB query can be huge (10+ MB easily)
yeah it all looks good i have looked at it
22 replies
CC#
Created by kmanjt on 2/7/2024 in #help
situation where the response to an InfluxDB query can be huge (10+ MB easily)
would you by any chance be familiar with the influxdb3 csharp nuget package?
22 replies
CC#
Created by kmanjt on 2/7/2024 in #help
situation where the response to an InfluxDB query can be huge (10+ MB easily)
in prod this is in a very resource constrained environment so yes
22 replies
CC#
Created by kmanjt on 2/7/2024 in #help
situation where the response to an InfluxDB query can be huge (10+ MB easily)
i believe its something to do with LOH fragmentation but i am really a noob on this topic
22 replies