Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Mike Pfeiffer mikepfeiffer

🏠
Working from home
View GitHub Profile
@mikepfeiffer
mikepfeiffer / acrTask.sh
Created Nov 12, 2020
Create ACR Task to Build Docker Image on GitHub Commit
View acrTask.sh
az acr task create -t node-demo:{{.Run.ID}} -n node-demo -r <acr name> \
-f Dockerfile -c https://github.com/mikepfeiffer/node-docker-demo.git \
--pull-request-trigger-enabled true \
--git-access-token <token>
@mikepfeiffer
mikepfeiffer / CreateWebApp.ps1
Last active Nov 7, 2021
Create App Service via Azure PowerShell
View CreateWebApp.ps1
# Create variables
$webappname = "mywebapp$(Get-Random)"
$rgname = 'webapps3-dev-rg'
$location = 'westus2'
# Create a resource group
New-AzResourceGroup -Name $rgname -Location $location
# Create an App Service plan in S1 tier
New-AzAppServicePlan -Name $webappname -Location $location -ResourceGroupName $rgname -Tier S1
@mikepfeiffer
mikepfeiffer / gist:7a3a8d12a42ec705233ceee3f3844a35
Last active Oct 27, 2021
Create App Service via Azure CLI
View gist:7a3a8d12a42ec705233ceee3f3844a35
az group create -n webapps-dev-rg -l westus2
az appservice plan create --name webapps-dev-plan \
--resource-group webapps-dev-rg \
--sku s1 \
--is-linux
az webapp create -g webapps-dev-rg \
-p webapps-dev-plan \
-n mp10344884 \
@mikepfeiffer
mikepfeiffer / gist:53453a98d62991dfdb5da40beb6229d5
Created Apr 27, 2020
PowerShell Script to Create Azure Custom RBAC Role
View gist:53453a98d62991dfdb5da40beb6229d5
CD $HOME
wget https://gist.github.com/mikepfeiffer/176776a8758b4e2910554a5c33392c12/raw/e48369b8aa73348606e76cbebc603d9e89c56666/customRoleDefinition.json
$subscription_id = (Get-AzContext).Subscription.id
(Get-Content -Path $HOME/customRoleDefinition.json) -Replace 'SUBSCRIPTION_ID', $subscription_id |
Set-Content -Path $HOME/customRoleDefinition.json
New-AzRoleDefinition -InputFile ./customRoleDefinition.json
@mikepfeiffer
mikepfeiffer / customRoleDefinition.json
Created Apr 27, 2020
Custom Role Definition (Azure RBAC)
View customRoleDefinition.json
{
"Name": "Virtual Machine Operator (Custom)",
"Id": null,
"IsCustom": true,
"Description": "Allows to start and stop (deallocate) Azure VMs",
"Actions": [
"Microsoft.Compute/*/read",
"Microsoft.Compute/virtualMachines/deallocate/action",
"Microsoft.Compute/virtualMachines/start/action"
],
View gist:b6687e359d6c0c2562f6574e7a524dd8
#cloud-config
package_upgrade: true
packages:
- httpd
@mikepfeiffer
mikepfeiffer / New-LabUser.ps1
Created Apr 15, 2020
This function creates AD users intended for lab use.
View New-LabUser.ps1
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$false)]
[System.Int32]
$count = 1,
[Parameter(Position=2, Mandatory=$true)]
[System.String]
$Password,
@mikepfeiffer
mikepfeiffer / NewWebServer.ps1
Created Mar 9, 2020
Quick AZ PowerShell Script to Create a Web Server
View NewWebServer.ps1
param(
$Name = 'WEB1',
$Location = 'westus2',
$ResourceGroup = 'WebServers'
)
New-AzResourceGroup -Name $ResourceGroup -Location $Location
$params = @{
Name = $Name
@mikepfeiffer
mikepfeiffer / newVM.sh
Created Mar 8, 2020
Quick Azure CLI script to create a Windows VM
View newVM.sh
#!/bin/bash
az group create --name WebServers --location westus2
az vm create \
--resource-group WebServers \
--name WEB1 \
--image win2016datacenter \
--admin-username sysadmin \
--size Standard_DS2_v2
@mikepfeiffer
mikepfeiffer / utils.ps1
Last active Nov 21, 2021
PS Function that creates an Azure Service Principal
View utils.ps1
function New-Sp {
param($Name, $Password)
$spParams = @{
StartDate = Get-Date
EndDate = Get-Date -Year 2030
Password = $Password
}
$cred= New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property $spParams