Skip to content

Instantly share code, notes, and snippets.

View sjwaight's full-sized avatar
😎
Happy Days

Simon Waight sjwaight

😎
Happy Days
View GitHub Profile
@sjwaight
sjwaight / create-azure-webapp.sh
Last active June 30, 2017 03:53
bash script that can be used to setup a new App Service Plan and Web App instance
#!/bin/sh
azuresub=$1
demolocation=$2
demoresourcegroup=$3
mysqlservername=$4
mysqladminuser=$5
mysqladminpass=$6
appplanname=$7
webappname=$8
@sjwaight
sjwaight / enable-phpmyadmin.sh
Last active June 30, 2017 04:32
bash script that enables the phpMyAdmin Site Extension on an Azure Web App
#!/bin/sh
azuresub=$1
demoresourcegroup=$2
webappname=$3
deployuser=$4
deploypass=$5
# CAUTION! RESTS CREDS for *all* Web Apps
# az webapp deployment user set --user-name $deployuser --password $deploypass
@sjwaight
sjwaight / update-mysql-firewall.sh
Last active June 30, 2017 04:54
bash script to set firewall rules for an Azure Database for MySQL instace
#!/bin/sh
azuresub=$1
demoresourcegroup=$2
mysqlservername=$3
firstip=$4
secondip=$5
thirdip=$6
fourthip=$7
@sjwaight
sjwaight / DeplyVMSnap.ps1
Created July 31, 2017 00:19
PowerShell script demonstrating how you can bootstrap a VM to install IIS, ASP.Net, Web Deploy and a custom ASP.Net solution
$workingFolder = "C:\temp\"
$packerFolder = "C:\DeployTemp\a\"
$webPIURL = "http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi"
$webPIInstaller = $workingFolder + "WebPlatformInstaller_amd64_en-US.msi"
$webPIExec = $env:ProgramFiles + "\Microsoft\Web Platform Installer\WebPiCmd-x64.exe"
$webDeployPackage = $packerFolder + "MyWebsite.API.zip"
$webDeployParams = $packerFolder + "MyWebsite.API.SetParameters.xml"
# Create working directory
New-Item $workingFolder -Type Directory -Force
@sjwaight
sjwaight / DeployVMSnapDsc.ps1
Created July 31, 2017 00:26
PowerShell script demonstrating how you can bootstrap a VM to install IIS, ASP.Net, Web Deploy and a custom ASP.Net solution using PowerShell DSC.
Configuration Main
{
Node ('localhost')
{
WindowsFeature WebServerRole
{
Name = "Web-Server"
Ensure = "Present"
}
@sjwaight
sjwaight / RegisterVmssImage.ps1
Created July 31, 2017 01:03
PowerShell script that can be used to create a VM Image in Azure based on a supplied VHD
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$imageResourceGroupName,
[Parameter(Mandatory=$True)]
[string]$imageResourceGroupAzureRegion,
[Parameter(Mandatory=$True)]
[string]$osDiskVhdUri,
[Parameter(Mandatory=$True)]
[string]$baselineImageName,
@sjwaight
sjwaight / KevVaultUtils.cs
Created August 8, 2017 01:18
Sample Azure Key Vault Service Principal Auth Token helper class.
namespace MyDemo.Website.WebApi.Helpers
{
public static class KevVaultUtils
{
// You could also utilise a certificate-based service principal as well
// Yes, these are hardcoded :)
private const string kvSP = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
private const string kvSPkey = "NOTREALLYTHEPASSWORD";
public static async Task<string> GetToken(string authority, string resource, string scope)
@sjwaight
sjwaight / Global.asax.cs
Last active August 8, 2017 04:23
Sample startup code showing how we can configure a VMSS instance based on its hostname and role.
namespace MyDemo.Website.WebApi
{
public class WebApiApplication : System.Web.HttpApplication
{
// This value is used if for some reason the configuration doesn't have a defined
// application insights instrumentation key
private const string DefaultAppInsightsKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// Yes, these are hardcoded - need to change? Recompile and build VM Image and redeploy.
private const string ConfigurationDbId = "apiconfigs";
@sjwaight
sjwaight / runtimeconfig.json
Last active August 8, 2017 04:26
Example configuration document used to configure instances in a VMSS
{
"id": "swtst01-webapi",
"AccessKey": "MATCHES_KEY_OF_CONFIG DB",
"AppInsightsKey": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy",
"LoggingDatabaseAccount": "https://myruntimedb.documents.azure.com:443/",
"LoggingDatabaseKey": "COSMOS_DB_KEY_OF_DBACCOUNT",
"LoggingDatabase": "runtimeitems",
"LoggingDatabaseCollection": "runtimedatabases",
}
@sjwaight
sjwaight / keyvault-params-versioned.json
Created October 6, 2017 06:22
Key Vault reference with a version in an ARM template parameter file.
"adminPassword": {
"reference": {
"keyVault": {
"id": "/subscriptions/{subscription-guid}/resourceGroups/{keyvault-rg}/providers/Microsoft.KeyVault/vaults/ProvisioningVault"
},
"secretName": "LocalAdminPass",
"secretVersion": "6A12A286385949DB8B5F82AFEF85CAE9"
}
}