Skip to content

Instantly share code, notes, and snippets.

@ahelland
ahelland / DeviceprofileHTTP.cs
Created February 14, 2018 09:47
Implementing the OAuth Deviceprofile Flow with plain HTTP calls
string ClientId = "guid-from-portal";
string resource = "00000002-0000-0000-c000-000000000000";
public class DCR
{
public string device_code { get; set; }
public string message { get; set; }
public string user_code { get; set; }
public string interval { get; set; }
public string expires_in { get; set; }
@ahelland
ahelland / DeviceprofileADAL.cs
Created February 14, 2018 09:50
Implementing the OAuth Deviceprofile Flow using ADAL
[HttpGet]
public async Task<IActionResult> LoginADAL()
{
AuthenticationContext ctx = null;
ctx = new AuthenticationContext("https://login.microsoftonline.com/common");
DeviceCodeResult codeResult = ctx.AcquireDeviceCodeAsync(resource, ClientId).Result;
DCR dcr = new DCR { message = codeResult.Message,
device_code = codeResult.DeviceCode,
expires_in = codeResult.ExpiresOn.ToString(),
@ahelland
ahelland / api-playground.yaml
Created April 4, 2018 07:47
Kubernetes YAML definition for api-playground deployment/service referred to in "Building Microservices with AKS and VSTS — Part 2"
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: api-playground
spec:
template:
metadata:
labels:
app: api-playground
spec:
@ahelland
ahelland / ExternalDNS.yaml
Created April 11, 2018 07:03
Kubernetes YAML definition for ExternalDNS referred to in "Building Microservices with AKS and VSTS — Part 3"
apiVersion: v1
kind: ServiceAccount
metadata:
name: external-dns
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: external-dns
rules:
@ahelland
ahelland / api-playground-ingress.yaml
Created April 11, 2018 07:06
Kubernetes YAML definition for api-playground-ingress referred to in "Building Microservices with AKS and VSTS — Part 3"
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: api-playground-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/tls-acme: 'true'
spec:
tls:
- hosts:
@ahelland
ahelland / api-playground.yaml
Created April 18, 2018 08:04
Kubernetes YAML definition for api-playground referred to in "Building Microservices with AKS and VSTS — Part 4"
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: api-playground
spec:
template:
metadata:
labels:
app: api-playground
spec:
@ahelland
ahelland / Dockerfile.CI
Created April 18, 2018 08:06
Dockerfile for api-playground referred to in "Building Microservices with AKS and VSTS — Part 4"
FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
@ahelland
ahelland / azure-file-sc.yaml
Created April 18, 2018 08:09
Kubernetes YAML definition for azure-file-sc referred to in "Building Microservices with AKS and VSTS — Part 4"
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: azurefile
provisioner: kubernetes.io/azure-file
parameters:
storageAccount: k8sazurefiles
@ahelland
ahelland / azure-file-pvc.yaml
Created April 18, 2018 08:10
Kubernetes YAML definition for azure-file-pvc referred to in "Building Microservices with AKS and VSTS — Part 4"
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: azurefile
spec:
accessModes:
- ReadWriteOnce
storageClassName: azurefile
resources:
requests:
@ahelland
ahelland / api-playground-storage.yaml
Created April 18, 2018 08:12
Kubernetes YAML storage append for api-playground referred to in "Building Microservices with AKS and VSTS — Part 4"
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: "/mnt/azure"
name: volume
volumes:
- name: volume
persistentVolumeClaim: