Skip to content

Instantly share code, notes, and snippets.

View weeyin83's full-sized avatar

Sarah Lean weeyin83

View GitHub Profile
@weeyin83
weeyin83 / resources.md
Last active November 20, 2019 11:45
Deliver value within Azure without spending a penny!
@weeyin83
weeyin83 / CreateServicePrincipal.ps1
Created January 3, 2020 09:58
Create an Azure Service Principal in PowerShell
# Create the Service Principal, generates a random password
$sp = New-AzADServicePrincipal -DisplayName ServicePrincipalName
# Export the random password that was generated on creation
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret)
$UnsecureSecret = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$UnsecureSecret
@weeyin83
weeyin83 / CreateServicePrincipal.sh
Last active January 3, 2020 11:03
Create an Azure Service Principal via Azure CLI
az ad sp create-for-rbac --name ServicePrincipalDisplayName
@weeyin83
weeyin83 / CreateServicePrincipalCustomRole.ps1
Created January 3, 2020 11:04
Create an Azure Service Principal with Contributor access to a single resource group
# Create the Service Principal, generates a random password, grants the Service Principal Contributor access to only a single resource group
$sp = New-AzADServicePrincipal -DisplayName ServicePrincipalName -Role Contributor -Scope /subscriptions/zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz/resourceGroups/myResourceGroup
# Export the random password that was generated on creation
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret)
$UnsecureSecret = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$UnsecureSecret
@weeyin83
weeyin83 / GitHubActionWorkflowtoCreateVM.yml
Created January 6, 2020 10:11
Example workflow that can be used to create a VM in Azure
name: GitHub for IT Pro CI/CD Pipeline
env:
OUTPUT_PATH: ${{ github.workspace }}
on: [push]
jobs:
# Deploy VM in Azure
@weeyin83
weeyin83 / SmokeTest.sh
Last active January 17, 2020 11:36
Create an Azure Resource Group, create a free App Service Plan and create a Web App.
#Create a Resource Group called "rg-smoketest" within the East US region
az group create --name rg-smoketest --location "East US" --tags 'Usage=Test'
#Create an Azure App Service Plan called SmokeTestASP within the rg-smoketest Resource Group and use the Free tier
az appservice plan create --name SmokeTestASP --resource-group rg-smoketest --sku FREE --tags 'Usage=Test'
#Create an Azure Web App called smoke-test app within the rg-smoketest resource group and attach it to the SmokeTestASP plan
az webapp create --name smoketest-web --resource-group rg-smoketest --plan SmokeTestASP
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SpeakingLogs](
[LogId] [int] IDENTITY(1,1) NOT NULL,
[TalkDate] [date] NOT NULL,
[EventName] [varchar](255) NOT NULL,
[City] [varchar](255) NULL,
[Country] [varchar](255) NULL,
@weeyin83
weeyin83 / azcli-storage.sh
Last active May 22, 2020 09:26
Create a standard storage account
#Create the resource group
az group create \
--name rg-photostorage \
--location UKSouth
#Create the storage account
az storage account create \
--name sarahsphotos \
--resource-group rg-photostorage \
--location UKSouth \
azcopy sync "C:\Users\salean\Pictures\2019" "https://sarahsphotos.blob.core.windows.net/2019-photos?sv=2019-10-10&ss=bfqt&srt=sco&sp=rwdlacupx&se=2020-05-05T17:44:25Z&st=2020-05-22T09:44:25Z&spr=https&sig=m9mbnOaFs0eCNhcuTa9dOsWcXqKySg0xC5PwqVfFvvQ%3D"