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
// utilising RestSharp and Json.NET - get via Nuget.
private WorkItem GetWorkItem(string workItemIdentifier)
{
var restClient = new RestClient("https://account.visualstudio.com/defaultcollection");
restClient.Authenticator = new HttpBasicAuthenticator("username", "password");
// code removed here
var changes = GetWorkItemHistoryComments(restClient, workItemIdentifier);
@sjwaight
sjwaight / ShutdownAllVms.ps1
Last active August 29, 2015 14:05
Example script that shows you how you can retrieve all virtual machines in an Azure subscription and then shut them down.
# Based on the August 2014 PowerShell Cmdlets (v2.4 of Azure SDK)
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1"
Function ForceShutdownVM($virtualMachine)
{
Write-Host "Looking at host" $_.Name -ForegroundColor Yellow
if($_.Status -ne "StoppedDeallocated")
{
if($_.InstanceName -Like "*_IN_*")
{
@sjwaight
sjwaight / 01-Setup-Azure-SQL.ps1
Last active August 29, 2015 14:08
How to deploy two Azure SQL Database Servers in different Regions, provision a new database on one and then setup an active geo-replication relationship between the Servers.
# Helper Method from: https://github.com/guangyang/azure-powershell-samples/blob/master/create-azure-sql.ps1
# You can download this file as part of this repository: https://github.com/sjwaight/uha-azure-sample/
# Create a PSCrendential object from plain text password.
# The PS Credential object will be used to create a database context, which will be used to create database.
Function New-PSCredentialFromPlainText
{
Param(
[String]$UserName,
@sjwaight
sjwaight / 04-Setup-TrafficManager.ps1
Created November 2, 2014 13:38
Example of how to create a new Azure Traffic Manager instance.
# You can download this file as part of this repository: https://github.com/sjwaight/uha-azure-sample/
if($args.Count -eq 0)
{
Write-Host "ERROR: you must supply a unique traffic manager DNS prefix"
Exit 1
}
$tmDomain = "{0}.trafficmanager.net" -f $args[0]
@sjwaight
sjwaight / 02-Setup-CloudServices.ps1
Last active August 29, 2015 14:08
How you can provision an empty Azure Cloud Service ready for your application deployment.
# You can download this file as part of this repository: https://github.com/sjwaight/uha-azure-sample/
Function New-DeploymentRegion
{
Param(
[String]$RegionName
)
####
@sjwaight
sjwaight / 03-Deploy-WebRoles.ps1
Created November 2, 2014 13:41
How we can deploy a rebuilt Azure Package to two separate Cloud Services in different Regions.
# You can download this file as part of this repository: https://github.com/sjwaight/uha-azure-sample/
Function New-AzureCloudServiceDeployment
{
Param(
[String]$RegionName,
[String]$DeploymentPathPackage,
[String]$DeploymentPathConfig
)
public class ContosoCustomDatabaseInitializer : IDatabaseInitializer<SchoolContext>
{
public void InitializeDatabase(SchoolContext context)
{
if (context.Database.Exists())
{
if (!context.Database.CompatibleWithModel(true))
{
context.Database.Delete();
}
@sjwaight
sjwaight / create-linux-vm.ps1
Last active August 29, 2015 14:12
Create a new CentOS 7 Linux VM in Azure
# Script assumes you have setup your subscription and
# have a default storage account in West US.
# You should change these to values you want.
$cloudService = "{cloudservice}"
$hostname = "{dockermanagementhost}"
$linuxUser = "{linxuser}"
$linuxPass = "{linxpasswd}"
$location = "West US"
@sjwaight
sjwaight / setup-docker-manager.sh
Last active August 29, 2015 14:12
Bash Script to setup our Docker management host.
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# pull down the necessary bits to install node
curl -sL https://rpm.nodesource.com/setup | bash -
"osProfile": {
"computername": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
}