Skip to content

Instantly share code, notes, and snippets.

View lukemurraynz's full-sized avatar
☁️
Breaking things!

Luke Murray lukemurraynz

☁️
Breaking things!
View GitHub Profile
@lukemurraynz
lukemurraynz / main.bicep
Last active August 28, 2023 01:34
VNET and NSG creation Azure Bicep
@description('Name of the virtual network.')
param vnetName string = 'myVnet'
@description('Name of the first subnet.')
param subnet1Name string = 'subnet1'
@description('Name of the second subnet.')
param subnet2Name string = 'subnet2'
@description('Name of the first network security group.')
@lukemurraynz
lukemurraynz / Initiate-DakaraSuperWeapon.ps1
Last active June 8, 2023 01:50
Deletes all resource groups under a management group except for the ones with a specific tag.
# This runbook deletes all resource groups under a management group except for the ones with a specific tag.
<#
.SYNOPSIS
Deletes all resource groups under a management group except for the ones with a specific tag.
.DESCRIPTION
This script deletes all resource groups under a specified management group except for the ones with a specific tag. It can also delete policy assignments and subscription role assignments if specified.
.PARAMETER ManagementGroupId
The ID of the management group to delete resource groups under. WARNING: This script will delete all resource groups under the specified management group except for the ones with the specified tag. Make sure you have specified the correct management group ID, or you may accidentally delete resources that you did not intend to delete.
@lukemurraynz
lukemurraynz / New-AzCountryIPGroup.p1
Created January 1, 2023 11:36
Creates an Azure IP group, with the IP address ranges for various countrues.
function New-AzCountryIPGroup {
<#
.SYNOPSIS
Creates an Azure IP group, with the IP address ranges for various countrues.
The code does the following:
1. It downloads the IP address ranges for the country specified.
2. It checks if the IP Group already exists, if it does, it adds the IP addresses to the existing IP Group.
3. If the total number of IP addresses is less than 5000, it will add the IP addresses to the existing IP Group.
4. If the total number of IP addresses is over 5000, it will create a new IP Group, with the same name as the existing IP Group, and it will add the IP addresses to the new IP Group.
5. If the new IP Group is over 5000, it will create a new IP Group, with the same name as the existing IP Group, and it will add the IP addresses to the new IP Group.
@lukemurraynz
lukemurraynz / AzureStaticWebAppsCICD.yml
Created November 14, 2022 00:45
Azure Static Web Apps CI/CD
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
@lukemurraynz
lukemurraynz / python.sqldb.txt
Last active August 16, 2022 23:24
python.sql.ipynb
#Libraries
import pyodbc
#Connection to SQL database
server = 'tcp:SQLSERVER.database.windows.net'
database = 'DBNAME'
username = '[email protected]'
password = 'password'
//Related to a Blog Article: https://luke.geek.nz for setting up Azure Naming Tool.
///Parameter Setting
param location string = resourceGroup().location
//Adjust Parameter values to match your naming conventions
param serverfarms_AzNamingTool_ASP_Prod_name string = 'AzNamingTool-ASP-Prod'
param storageAccounts_aznamingstgacc_name string = 'aznaming'
// The following Parameters are used add Tags to your deployed resources. Adjust for your own needs.
#requires -Version 3.0 -Modules Az.Accounts, Az.Resources
<#
.SYNOPSIS
PowerShell Azure Automation Runbook for Starting/Stopping Virtual Machines.
.AUTHOR
Luke Murray (https://github.com/lukemurraynz/)
.VERSION
1.0 - 28/04/22 - script versioned to '1.0'.
.DESCRIPTION
1. The script first checks if today is a holiday by making a call to the Abstract API.
@lukemurraynz
lukemurraynz / Deallocate-AzureVirtualMachine.ps1
Last active May 12, 2022 06:12
PowerShell Azure Automation Runbook for Stopping Virtual Machines, that have been Shutdown within the Windows Operating System (Stopped and not Deallocated).
#requires -Version 3.0 -Modules Az.Accounts, Az.AlertsManagement
<#
.SYNOPSIS
PowerShell Azure Automation Runbook for Stopping Virtual Machines, that have been Shutdown within the Windows Operating System (Stopped and not Deallocated).
.AUTHOR
Luke Murray (https://github.com/lukemurraynz/)
#>
[OutputType('PSAzureOperationResponse')]
param (
@lukemurraynz
lukemurraynz / Deploy-AzVNETS2S.bicep
Created March 27, 2022 08:09
Deploy-AzVNETS2S.bicep
targetScope = 'resourceGroup'
///Parameter and Variable Setting
@minLength(3)
@maxLength(6)
param sitecode string = ''
param environment string = ''
param contactEmail string = ''
#requires -Version 1.0
# Variables
#Enter your subscription name
$subscriptionName = 'luke.geek.nz'
#Enter the name of yuour
$policyDisplayName = 'Deploy - Log Analytics' #Cant Exceed 24 characters
$location = 'australiaeast'
$resourceGroup = 'aoegeek-rg'
$UsrIdentityName = 'AOE_ManagedIdentityUsr'
$param = @{