Skip to content

Instantly share code, notes, and snippets.

@JKerens
JKerens / Program.cs
Created March 9, 2026 23:52
Class Examples
using Basics;
// Similar to Schemas in Pyschology, we need to break concepts apart
// Like Red Ball != Red Apple, now red round things are 2 different concepts
// In programming, we have data types to help us break apart concepts
// "Mary had a little lamb" is a string, 1 + 1 is numbers
// What we do with these values are COMPLETELY different
// This is why some questions might start sounding dumb
// How data types work in C#
@JKerens
JKerens / example.bicepparam
Created November 26, 2025 19:03
Mutating Array w/ Spread Operator
import { overrideMatchValues } from './helpers.bicep
param routingRuleSetsOptions = [
{
name: corRuleSet.name
routingRules: [
{
name: corsRule.name
properties: {
order: corsRule.properties.order
@JKerens
JKerens / Directory.Build.targets
Created October 31, 2025 19:31
Adding bicep publish-extension into your csproj
<Project>
<PropertyGroup>
<!-- All the identifiers to target -->
<RuntimeIdentifiers>win-x64;linux-x64;osx-arm64</RuntimeIdentifiers>
<BicepCmdBase>bicep publish-extension</BicepCmdBase>
<BicepCmdOsx>--bin-osx-arm64 "$(MSBuildProjectDirectory)/bin/$(Configuration)/$(TargetFramework)/osx-arm64/publish/$(AssemblyName)"</BicepCmdOsx>
<BicepCmdLinux>--bin-linux-x64 "$(MSBuildProjectDirectory)/bin/$(Configuration)/$(TargetFramework)/linux-x64/publish/$(AssemblyName)"</BicepCmdLinux>
<BicepCmdWin>--bin-win-x64 "$(MSBuildProjectDirectory)/bin/$(Configuration)/$(TargetFramework)/win-x64/publish/$(AssemblyName).exe"</BicepCmdWin>
<BicepCmdTarget>--target "$(MSBuildProjectDirectory)/bin/$(AssemblyName)"</BicepCmdTarget>
@JKerens
JKerens / main.bicep
Created October 24, 2025 19:01
Check for Subnet Overlaps
type SubnetRange = {
start: int
end: int
cidr: string
}
var subnets = loadJsonContent('subnets.json')
var addressPrefixes = map(subnets, s => s.addressPrefix)
@JKerens
JKerens / main.bicep
Last active October 17, 2025 14:25
Subnet calculator in Azure Bicep to help with giant vNets
import { getSubnets, Subnet, sliceSubnet } from 'networkUtils.bicep'
var network = getSubnets('10.0.0.0', 20, 24)
var sliced = sliceSubnet(network[0], 25)
output sliced Subnet[] = sliced // result in output.sliced.json
output network Subnet[] = take(network, 3) // result in output.network.json
@JKerens
JKerens / Az.Sql.Extensions.psm1
Last active October 18, 2023 14:24
Addons to Az.Sql to query the table APIs from the portal
<#
.EXAMPLE
$db = Get-AzSqlDatabase -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <DatabaseName>
Get-AzSqlDatabaseSchema -ResourceId $db.ResourceId
#>
function Get-AzSqlDatabaseSchema {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string]$ResourceId
@JKerens
JKerens / TheFix.psm1
Created March 5, 2023 20:51
A basic example using enums as a ValidateSet attribute without maintaining a bunch of string arrays
using namespace System.Management.Automation
<#
.DESCRIPTION
This example uses enums so we can match based on type instead of strings
Also, IValidateSet will pick up new additions automagically ^_^
#>
enum Command {
Publish
Download
NotImplementedWillThrow
@JKerens
JKerens / Az.Module.Cache.psm1
Last active March 3, 2023 19:47
Azure PowerShell Caching Idea
$Script:cache ??= [ordered]@{}
<#
.EXAMPLE
Import-Module .\Az.Module.Cache.psm1
$servers = Get-CachedItem -ValueFactory { Get-AzResource -ResourceType "Microsoft.Sql/servers" } -Verbose
#>
function Get-CachedItem {
param(
[Parameter(Mandatory = $true)]
@JKerens
JKerens / deploy.bicep
Last active December 12, 2022 16:14
Subnet Bicep Deployment
targetScope = 'subscription'
param location string = deployment().location
param uniqueDeploymentId string = newGuid()
resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: 'my-rg'
location: location
}
@JKerens
JKerens / SqlMonitor.psm1
Created August 4, 2022 17:44
PowerShell tasks with a wrapper that monitors metrics of interest while a long task is running
#requires -Module Az.Sql
#requires -Module Az.Monitor
<#
.DESCRIPTION
When running a reindex on a Sql database sometime the fragmentation is so bad it will grow the database to the max size before finishing.
This example shows how to attach monitoring to an action.
.EXAMPLE
$db = Get-AzSqlDatabase -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <DatabaseName>