Skip to content

Instantly share code, notes, and snippets.

@stcox
stcox / backup-apim.ps1
Created November 23, 2023 00:53
Azure Automation Powershell Runbook - Backup Azure API Management with Az and Managed Id - 2023
<#
.CREDIT
Based on: https://github.com/azureautomation/backup-azure-api-management-automation-script/blob/master/Backup-AzureAPIM.ps1
Updated AzureRM commands to Az commands and RunAsConnection to Managed Id
.SYNOPSIS
This Azure Automation runbook automates Azure API Management backup to Blob storage and deletes old backups from blob storage.
.DESCRIPTION
You should use this Runbook if you want manage Azure API Management backups in Blob storage.
@stcox
stcox / gist:c8464992f414b600f50dfcfcb1c91278
Created March 12, 2023 15:04
azure devops template specs
https://msftplayground.com/2021/03/azure-template-specs-managed-via-azure-devops/
https://msftplayground.com/2021/02/the-new-and-shiny-azure-template-specs/
@stcox
stcox / ps-detect-datadisks-2.ps1
Last active November 18, 2021 15:24
arm template deployment script to detect whether data disks already exist in resource group, expecting vm1-datadisk, vm2-datadisk, etc.
param([string] $resourceGroup, $vmCount)
$vmArray = [bool[]]::new($vmCount)
$disksFound = Get-AzDisk -ResourceGroupName $resourceGroup | Select-Object -Property Name
foreach ($disk in $disksFound)
{
$vmArray[[int]$disk.Name.Substring(2, 1)] = 'true'
}
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['text'] = $vmArray | convertto-json -AsArray -EnumsAsStrings
param([string] $resourceGroup, $vmCount)
$vm = [bool[]]::new($vmCount)
$disksFound = Get-AzDisk -ResourceGroupName $resourceGroup | Select-Object -Property Name
foreach ($disk in $disksFound)
{
$vmIndex = $disk.Name.Substring($disk.Name.Length - 1)
$vm[[int]$vmIndex-1] = 'true'
}
@stcox
stcox / align-input-in-label.css
Last active August 27, 2018 19:27
Vertically align input element within label element
/* where <label><input type=checkbox/radio></input></label>*/
input [type=checkbox/radio]{
float: left;
margin: 3px 5px 0 0;
}
jQuery(function(){
// Activate Monthly button when page first loads
jQuery('#pf-menu a[href$="monthly"]').addClass("current");
});
jQuery("#pf-menu a").click(function() {
// Switch Active button
jQuery('.pf-menu-button .current').removeClass("current");
jQuery(this).addClass("current");
// Switch active plans
var paymentFrequency = jQuery(this).attr('href').substring(1);
#move next 4 lines to /etc/nginx/nginx.conf if you want to use fastcgi_cache across many sites
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
server_name example.com www.example.com;