Skip to content

Instantly share code, notes, and snippets.

View stijnmoreels's full-sized avatar
🧪
Testing better than yesterday

Stijn Moreels stijnmoreels

🧪
Testing better than yesterday
View GitHub Profile
private static Outcome<T, string[]> Deserialize<T>(JObject obj)
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
var serializer = new JsonSerializer
{
NullValueHandling = NullValueHandling.Ignore,
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceBusQueueMessagePump((ISecretProvider secretProvider) => secretProvider.GetRawSecretAsync("ServiceBus:Queue:ConnectionString"))
.WithServiceBusMessageHandler<OrdersMessageHandler, Order>();
}
public class OrdersMessageHandler : IMessageHandler<Order>
{
private readonly ILogger _logger;
public OrdersMessageHandler(ILogger<OrdersMessageHandler> logger)
{
_logger = logger
}
public async Task ProcessMessageAsync(
public void ConfigureServices(IServiceCollection services)
{
services.AddHealthChecks();
services.AddAzureBlobStorage("UseDevelopmentStorage=true", "arcusblobs");
services.AddTcpHealthProbes("Health:Tcp:Port");
}
public void ConfigureServices(IServiceCollection services)
{
services.AddAutoInvalidateKeyVaultSecretBackgroundJob(
"MyServiceBusTopicPrefix",
"ServiceBus:Topic:ConnectionString");
}
string connectionString = "Server=sample-server;Database=sample-database;User=admin;Password=123";
using (var measurement = DependencyMeasurement.Start())
{
// Interact with database
var products = await _repository.GetProducts();
_logger.LogSqlDependency(connectionString, "my-table", "get-products", isSuccessful: true, measurement: measurement);
// Output: "SQL Dependency sample-server for sample-database/my-table for operation get-products in 00:00:01.2396312 at 03/23/2020 09:32:02 +00:00 (Successful: True - Context: )"
}
public void Configure(IApplicationBuilder app, IWebHostEvironment env)
{
app.UseRequestTracking();
...
app.UseMvc();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseRequestTracking(options =>
{
// Whether or not the HTTP request body should be included in the request tracking logging emits.
// (default: `false`)
options.IncludeRequestBody = true;
// Whether or not the configured HTTP request headers should be included in the request tracking logging emits.
// (default: `true`)
ublic void ConfigureServices(IServiceCollection services)
{
services.AddHttpCorrelation();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHttpCorrelation();
Log.Logger = new LoggerConfiguration()
public void ConfigureServices()
{
services.AddMvc(mvcOptions => mvcOptions.Filters.AddJwtTokenAuthorization());
}