Skip to content

Instantly share code, notes, and snippets.

@ralacher
ralacher / policy.xml
Created September 9, 2022 17:04
Azure API Management policy to selectively enforce mTLS
<policies>
<inbound>
<base />
<choose>
<!-- No certificate required -->
<when condition="@(context.Request.Headers.GetValueOrDefault("Host").Equals("no-mtls.example.org", StringComparison.OrdinalIgnoreCase))">
<return-response>
<set-status code="200" reason="OK" />
<set-body>No certificate required for no-mtls.example.org</set-body>
@ralacher
ralacher / az-cli.sh
Created July 23, 2021 19:22
ARM Template
# Azure CLI command used to deploy the ARM template
az deployment group create \
--resource-group MyResourceGroup \
--name MyDeployment \
--template-file azureDeploy.json \
--parameters \
environment=dev \
primaryRegion=southcentralus \
primaryRegionAbbrev=scus \
databaseName=MyDatabase
@ralacher
ralacher / __main__.py
Last active July 8, 2021 14:33
Customer-Managed Key with Pulumi
import pulumi
import pulumi_azure_native as azure_native
from pulumi import Output
config = pulumi.Config()
# Your AD Tenant ID
TENANT_ID = ''
# Object ID for the principal running Pulumi to access Key Vault
KV_ACCESS_POLICY = ''
# Resource name used for all Azure resources in this demo
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication.Internal;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Graph;
using Newtonsoft.Json;
@ralacher
ralacher / Function1.cs
Created June 23, 2021 12:55
Get Security Groups
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Graph;
using Microsoft.Identity.Client;
using Newtonsoft.Json.Linq;
@ralacher
ralacher / crash.log
Last active March 3, 2021 18:21
Terraform v0.14.7 crash.log
2021/03/03 17:06:12 [INFO] Terraform version: 0.14.7 v0.14.7
2021/03/03 17:06:12 [INFO] Go runtime version: go1.16
2021/03/03 17:06:12 [INFO] CLI args: []string{"/usr/bin/terraform", "apply"}
2021/03/03 17:06:12 [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2021/03/03 17:06:12 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021/03/03 17:06:12 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/03/03 17:06:12 [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2021/03/03 17:06:12 [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2021/03/03 17:06:12 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2021/03/03 17:06:12 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
@ralacher
ralacher / embed.js
Created September 10, 2020 18:38
Power BI embedded snippet
// Using Power BI sandbox tool
// https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html
embedReport() {
// Copy embed application token from sandbox
const txtAccessToken = ''
// Copy URL from sandbox
const txtEmbedUrl = 'https://app.powerbi.com/reportEmbed?reportId=f6bfd646-b718-44dc-a378-b73e6b528204&groupId=be8908da-da25-452e-b220-163f52476cdd&config=eyJjbHVzdGVyVXJsIjoiaHR0cHM6Ly9XQUJJLVVTLU5PUlRILUNFTlRSQUwtcmVkaXJlY3QuYW5hbHlzaXMud2luZG93cy5uZXQiLCJlbWJlZEZlYXR1cmVzIjp7Im1vZGVybkVtYmVkIjp0cnVlfX0%3d'
// Copy report id from sandbox
const txtEmbedReportId = 'f6bfd646-b718-44dc-a378-b73e6b528204'
// Get models. models contains enums that can be used.
@ralacher
ralacher / angular-azure-pipelines.yml
Created September 10, 2020 18:21
Azure DevOps Build Pipeline Examples
# Pipeline to build, test, and package an Angular SPA
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: UseNode@1
@ralacher
ralacher / az-cli.md
Last active May 8, 2024 06:56
Azure CLI Cheat Sheet

Az CLI

Collection of commands I've found useful and don't want to forget or lose from my shell history.

Account

# Set the context
az account set -s $subscriptionName
# Show context information
az account show
# Login with a service principal
az login --service-principal --username $clientId --password $clientSecret --tenant $tenantId
### Keybase proof
I hereby claim:
* I am rlacherksu on github.
* I am rlacher (https://keybase.io/rlacher) on keybase.
* I have a public key whose fingerprint is FE11 267C 0704 83CC 5AE4 BD42 2DCE 4C8E EFF5 7644
To claim this, I am signing this object: