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
# Convert plaintext to secure string
$adminPass = ConvertTo-SecureString -String 'L0Lcat5^_^!' -AsPlainText -Force
# Add the password as a Secret
Set-AzureKeyVaultSecret -VaultName 'ProvisionVault' -Name 'LocalAdminPass' -SecretValue $adminPass
"adminPassword": {
"reference": {
"keyVault": {
"id": "/subscriptions/{subscription-guid}/resourceGroups/{keyvault-rg}/providers/Microsoft.KeyVault/vaults/ProvisioningVault"
},
"secretName": "LocalAdminPass"
}
}
# Log into our Account.
Login-AzureRmAccount
# Create a new Resource Group
New-AzureRmResourceGroup -Name 'sw-sec-demo' -Location 'West US'
# Create new Key Vault instance - important to add "EnabledForDeployment"
New-AzureRmKeyVault -VaultName 'ProvisioningVault' -ResourceGroupName 'sw-sec-demo' -Location 'West US' -EnabledForTemplateDeployment
@sjwaight
sjwaight / web.2.0.config
Created November 17, 2013 02:34
Sample web.config for a basic forms based authentication web application that is using membership and role providers.
<?xml version="1.0"?>
<configuration>
<appSettings />
<connectionStrings>
<!-- you'll need to change this to match your server - the one below is using the default local instance with Windows Auth. -->
<add name="aspnetmembers" connectionString="server=.;initial catalog=AuthDemoApp;Integrated Security=SSPI"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
<authentication mode="Forms">
@sjwaight
sjwaight / connectionStrings.config
Created November 17, 2013 09:00
Sample connection strings configuration file from the Thinktecture IdentityServser setup for the associated blog.
<connectionStrings>
<!-- configuration data like endpoints, protocol config, relying parties etc... -->
<add name="IdentityServerConfiguration"
connectionString="server=.;initial catalog=IdentityServerConfiguration;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
<!-- user database -->
<add name="ProviderDB"
connectionString="server=.;initial catalog=AuthDemoApp;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
</connectionStrings>
{
"_comment": "originally from: https://github.com/Azure/azure-quickstart-templates/blob/master/201-web-app-vm-dsc/azuredeploy.json"
"name": "DSCExt1",
"type": "extensions",
"location": "[parameters('vmLocation')]",
"apiVersion": "2015-05-01-preview",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
],
"tags": {
@sjwaight
sjwaight / enforce-tags.json
Last active February 9, 2016 01:45
Shows how you can enforce use of tags on new resources
"if": {
"not": {
"anyOf": [
{
"field": "tags",
"containsKey": "CostCentre"
},
{
"field": "tags",
{
"Name": "Virtual Machine Power Manager",
"IsCustom": true,
"Description": "Can monitor, stop, start and restart v2 ARM virtual machines.",
"Actions": [
"Microsoft.Storage/*/read",
"Microsoft.Network/*/read",
"Microsoft.Compute/*/read",
"Microsoft.Compute/virtualMachines/start/action",
"Microsoft.Compute/virtualMachines/powerOff/action",
@sjwaight
sjwaight / sample-runbook-service-principal-credentials.ps1
Last active February 19, 2016 03:32
Shows how we can use a Service Principal identity in an Azure Automation Runbook.
param (
[Parameter(Mandatory=$false)]
[String]$AzureCredentialAssetName = "VMPowerServicePrincipal",
[Parameter(Mandatory=$false)]
[String]$AzureSubscriptionIDAssetName = "VMShutdownTargetSubscription",
[Parameter(Mandatory=$false)]
[String]$AzureTenantIDAssetName = "VMShutdownTargetTenant"
)
$myEmailOrUpn = 'some.user@some.doman'
# can use your mailbox login
$cred = Get-Credential
$exoSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication "Basic" -AllowRedirection
# Loads session and EXO Cmdlets
Import-PSSession $exoSession