Skip to content

Instantly share code, notes, and snippets.

@kevinhillinger
kevinhillinger / get-builds-and-their-status.ps1
Last active January 29, 2020 19:25
Azure DevOps REST API usage from Azure DevOps
# Setting the script to authenticate using the system access token on the Azure DevOps Build Agent
# Set the agent job to "Allow scripts to access OAuth token" in the build
$pat = "Bearer $env:System_AccessToken"
# this will be the correlation value used to collect all the builds
$sourceVersion = $env:BUILD_SOURCEVERSION
Write-Output ("##vso[task.setvariable variable=sourceVersion;]$sourceVersion")
$organizationName = ([System.Uri]$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI).Host.split('.')[0]
@kevinhillinger
kevinhillinger / deploy-ad-controller.ps1
Last active November 11, 2019 16:00
Create AD Controller
# variables
$location="<selected region>"
$name_suffix="<your student id>"
$group_name="identitylab"
# create the group
New-AzureRmResourceGroup -Name $group_name -Location $location
$template_uri="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/active-directory-new-domain/azuredeploy.json"
@kevinhillinger
kevinhillinger / api-app-manifest.json
Created October 24, 2019 18:38
Azure Active Directory - Securing an API with Azure API Management
{
"id": "f54fd36e-57c8-4408-a870-3ef2b3b4b685",
"acceptMappedClaims": null,
"accessTokenAcceptedVersion": null,
"addIns": [],
"allowPublicClient": null,
"appId": "da66ee7b-d762-4e19-8d7c-66a9974baeab",
"appRoles": [
{
"allowedMemberTypes": [
@kevinhillinger
kevinhillinger / create-service.sh
Last active September 25, 2019 17:46
Azure Meta Service Broker - Redis Cache Premium - PCF
# created the service broker via command
SECURITY_USER_NAME=<username>
SECURITY_USER_PASSWORD=<the password>
URL=http://meta-azure-service-broker.<public ip value here>.xip.io
cf create-service-broker meta-azure-service-broker $SECURITY_USER_NAME $SECURITY_USER_PASSWORD $URL
# enabled service for redis
cf enable-service-access azure-rediscache
@kevinhillinger
kevinhillinger / assign-user-to-access-kubeconfig.sh
Last active June 12, 2019 20:07
Azure AD Integration with AKS
# The following example assigns the Azure Kubernetes Service Cluster Admin Role to an individual user account.
# This is controlled via Azure AD -> Azure AKS (separate from AAD integration with
# AKS where someone can assign a user a cluster role
# Get the resource ID of your AKS cluster
AKS_CLUSTER=$(az aks show --resource-group myResourceGroup --name myAKSCluster --query id -o tsv)
# Get the account credentials for the logged in user
ACCOUNT_UPN=$(az account show --query user.name -o tsv)
@kevinhillinger
kevinhillinger / deploy.sh
Last active June 11, 2019 19:58
AKS Cluster with Windows Containers, Custom Virtual Network (VNet) with CNI
# get list of nodes
kubectl get nodes
# beta.kubernetes.io/os=windows
# taint
nodes=$(kubectl get no \
-o jsonpath="{.items[*].metadata.name}" \
-l=beta.kubernetes.io/os=windows)
@kevinhillinger
kevinhillinger / iis-prepull.yaml
Last active June 11, 2019 14:55
Pre-pulling base images using Windows Containers on AKS
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: prepull
spec:
selector:
matchLabels:
name: prepull
template:
metadata:
@kevinhillinger
kevinhillinger / azure-pipelines.yaml
Created June 5, 2019 18:48
Deploy container to Azure Container Registry from Azure DevOps
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
@kevinhillinger
kevinhillinger / 1-setup-resources.sh
Last active April 1, 2019 19:16
Azure API Management to Key Vault Integration - Client Certificate Authentication
rg=apim
location=eastus2
vnet=apim-vnet
az group create --name $rg --location $location
az network vnet create -n $vnet -g $rg -l $location \
--address-prefixes 10.0.0.0/16 \
--subnet-name default \
--subnet-prefixes 10.0.0.0/24
@kevinhillinger
kevinhillinger / add-log-analytics-ext-arm-tmpl.json
Last active March 28, 2019 16:12
Adding Log Analytics VM Extension to VM Scale Set with PowerShell
{
"name": "[concat(variables('vmNodeType0Name'),'OMS')]",
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "MicrosoftMonitoringAgent",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": {
"workspaceId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces/', parameters('omsWorkspacename')), '2015-11-01-preview').customerId]"