Skip to content

Instantly share code, notes, and snippets.

View brianhdk's full-sized avatar

Brian Holmgård Kristensen brianhdk

View GitHub Profile
public class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
string environment = Environment.GetEnvironmentVariable("AZURE_FUNCTIONS_ENVIRONMENT");
if (!string.Equals(environment, "Development", StringComparison.OrdinalIgnoreCase))
{
builder.Services.AddLogging(loggingBuilder => loggingBuilder
.AddSerilog(new LoggerConfiguration()
if (request == null)
return new BadRequestErrorMessageResult("Request is empty.");
if (string.IsNullOrWhiteSpace(request.Id))
return new BadRequestErrorMessageResult($"Missing required value for property '{nameof(ReindeerRescueRequest.Id)}'.");
if (!Guid.TryParse(request.Id, out Guid id))
return new BadRequestErrorMessageResult($"Value for property '{nameof(ReindeerRescueRequest.Id)}' is not a valid ID or has an invalid format (example of valid value and format for Unique Identifier (GUID): '135996C9-3090-4399-85DB-1F5041DF1DDD').");
Attempt attempt = await _attemptService.Get(id, expectedVersion: 2, token);
string body = await httpRequest.Read(logger);
T request;
try
{
request = JsonConvert.DeserializeObject<T>(body);
}
catch (JsonException ex)
{
{
"toyDistributionXmlUrl": "https://xmas2019.blob.core.windows.net/toydistribution/data.xml",
"message": "Good job! ..."
}
{
"id": "<<unikt id>>",
"toyDistribution": [
{
"childName": "Jeppe",
"toyName": "Lego Friends"
},
{
"childName": "Asta",
"toyName": "Fidgetspinner"
<ToyDistributionProblem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Toys>
<Toy Name="Dukkehus" />
<Toy Name="Barbie dukke" />
<Toy Name="Lyssværd" />
...
</Toys>
<Children>
<Child Name="Laurits">
<WishList>
async Task Main()
{
using (var httpClient = new HttpClient()) // store instance, dispose when your application shuts down
{
httpClient.BaseAddress = new Uri("https://vertica-xmas2019.azurewebsites.net");
var participateRequest = new ParticipateRequest
{
FullName = "",
EmailAddress = "",
{
"id": "<<id>>",
"locations": [
{
"name": "<<reindeer1>>",
"position": {
"lat": 21.366934221990263,
"lon": 42.37590954272628
}
},
{
"id": "srx1n4qctdh",
"countryCode": "<<countryCode>>",
"name": "<<name>>",
"location": {
"type": "Point",
"coordinates": [
21.366934221990263,
42.37590954272628
]
@brianhdk
brianhdk / santa-rescue-response.json
Created December 9, 2019 06:37
Santa Rescue Response
{
"zones": [
{
"reindeer": "Dancer",
"countryCode": "DE",
"cityName": "Cottbus",
"center": {
"lat": 51.7704,
"lon": 14.33
},