Skip to content

Instantly share code, notes, and snippets.

Working from home

Marc Bruins MarcBruins

Working from home
Block or report user

Report or block MarcBruins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:99c1c7c6d77de0aced1db19056f53cb3
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.Build.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;
MarcBruins / Dockerfile
Last active Apr 10, 2019
Plain functions dockerfile dotnet
View Dockerfile
FROM microsoft/dotnet:2.2-sdk AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
View gistnukeeper.cs
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.FSharp.Collections;
using Microsoft.FSharp.Core;
using NuKeeper.Abstractions.Inspections.Files;
using Paket;
namespace NuKeeper.Inspection.RepositoryInspection
MarcBruins / keyvault-secrets-from-appconfig.cs
Last active Jan 9, 2019
Read keyvault secrets from app config json
View keyvault-secrets-from-appconfig.cs
//1. Create a file for both classes
//2. Replace the IKeyVaultAccessClient with a concrete keyvault implementation
//3. Add it to the builder: builder.Add(new ReplaceTokensConfigurationSource(configuration, logger, client));
//4. Add secrets placeholder to the appsetings.json with the following pattern __secret__
/// <summary>
/// A JSON configuration source that replaces values from JSON that are tokenized with a value from Azure Key Vault,
/// using the tokenized value as lookup key.
/// </summary>
public sealed class ReplaceTokensConfigurationProvider : ConfigurationProvider, IDisposable
MarcBruins / AzureServicesAuthConnectionString.txt
Created Jan 7, 2019
AzureServicesAuthConnectionString sample
View AzureServicesAuthConnectionString.txt
AzureServicesAuthConnectionString RunAs=App;AppId=YOURAPPID;TenantId=YOURTENANTID;AppKey=OPTIONALAPPKEY
View pwd.cs
private string DbPassword = "MySuperSecretPassword";
View callingkeyvault.cs
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
var secret = await keyVaultClient.GetSecretAsync("").ConfigureAwait(false);
MarcBruins / possiblederefenceofnull.cs
Last active Jan 4, 2019
Possible dereference of a null reference sample
View possiblederefenceofnull.cs
public async Task<SearchCodeResult> Search(SearchCodeRequest search)
foreach (var repo in search.Repos)
//do search stuff
class SearchCodeRequest{
public IList<string>? Repos { get; set; }
MarcBruins / returningforuri.cs
Created Dec 16, 2018
Return value for uri trailing slash
View returningforuri.cs
public static Uri EnsureTrailingSlash(Uri uri)
return new Uri(uri.ToString() + "/");
public static Uri EnsureTrailingSlash(Uri? uri)
if(uri == null)
MarcBruins / returnullfornull.cs
Created Dec 16, 2018
Returning null for null Uri
View returnullfornull.cs
public static Uri EnsureTrailingSlash(Uri uri)
if (uri == null)
return null;
return new Uri(uri.ToString() + "/");
You can’t perform that action at this time.