Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Last active November 3, 2017 14:45
Show Gist options
  • Save chgeuer/67d09f345590ad7d2aa9 to your computer and use it in GitHub Desktop.
Save chgeuer/67d09f345590ad7d2aa9 to your computer and use it in GitHub Desktop.
Azure Automation Linux

src: http://aka.ms/is24

agenda

misc links

azure resource manager

Turn node.js into "Azure Resource Manager" Mode

azure config mode arm

Turn node.js into old Mode

azure config mode asm
azure config mode arm
azure group template list --json >> templates.json
azure group template download CoreOS.CoreOSAlpha.0.2.9-preview

azure config mode asm
azure storage account list --json
  • Microsoft.VirtualNetwork.1.0.4
  • Microsoft.CloudService.0.8.0-placeholder
  • Microsoft.ClassicStorage.0.3.5-preview
  • Microsoft.CustomScriptExtension.1.0.12
  • Microsoft.CustomScriptForLinux.1.0.3
  • Microsoft.TrafficManager.0.8.0-placeholder
  • Microsoft.CDN.0.8.0-placeholder
  • Microsoft.WebSite.0.2.2-preview
  • Microsoft.SQLDatabase.0.2.4-preview
  • Microsoft.DocumentDB.0.4.0-preview
  • Microsoft.WebSiteSQLDatabase.0.2.0-preview
  • Microsoft.Cache.1.0.1
  • Microsoft.DocumentDB.0.4.0-preview
  • Microsoft.Jetty.0.1.0-preview
  • Microsoft.MediaService.0.8.0-placeholder
  • Microsoft.MinecraftServer.1.8.6
  • Microsoft.NotificationHub.0.7.0-placeholder
  • Microsoft.MultiFactorAuthentication.0.8.0-placeholder
  • Microsoft.Scheduler.0.8.0-placeholder
  • Microsoft.Search.1.0.1-preview
  • Microsoft.ServiceGatewayManagementConsole.0.2.4-preview
  • Microsoft.WebSiteDeploySQLRedis.0.2.5-preview
  • SuccessBricksInc.ClearDBMySQLDatabase.0.2.1-preview
  • Cloudera.ClouderaEnterprise.4.12.18-preview

Login to Azure

npm install azure-cli
azure account clear
azure account import "Windows Azure MSDN - Visual Studio Ultimate-credentials.publishsettings"
azure account set "internal"
azure account list

Get the image

azure vm list --json
azure vm create DNS_PREFIX --community vmdepot-65-6-32 --virtual-network-name  -l "West Europe" USER_NAME [PASSWORD] [--ssh] [other_options]

Create an A5 instance

Command line for creating a PostgreSQL machine

Command line:

azure vm create-from cloudservicename machine.json --connect --verbose --json

machine.json

See the REST API for details.

{
	"RoleName": "database-vm-1",
	"RoleType": "PersistentVMRole",
	"RoleSize": "A5",
	"AvailabilitySetName" : "databases",
	"OSVirtualHardDisk": {
		"OS": "Linux",
		"HostCaching": "ReadWrite",
		"DiskName": "database-vm-1-disk",
		"DiskLabel": "database-vm-1-disk",
		"SourceImageName": "Debian-Wheezy-635506180993665396",
		"RemoteSourceImageLink": "http://account.blob.core.windows.net/vmdepot-images/TE-2014-11-03-debianwheezy-os-2014-11-03.vhd",
		"MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-1-disk.vhd"
	},
	"DataVirtualHardDisks": [
		{ "DiskLabel": "database-vm-1-data1", "Lun": "0", "MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-1-data1.vhd", "HostCaching": "ReadOnly", "LogicalDiskSizeInGB": "1023" },
		{ "DiskLabel": "database-vm-1-data2", "Lun": "1", "MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-1-data2.vhd", "HostCaching": "ReadOnly", "LogicalDiskSizeInGB": "1023" },
		{ "DiskLabel": "database-vm-1-xlog1", "Lun": "2", "MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-1-xlog1.vhd", "HostCaching": "ReadOnly", "LogicalDiskSizeInGB": "1023" } 
	],
	"ConfigurationSets": [
		{
			"ConfigurationSetType" : "LinuxProvisioningConfiguration",
			"HostName" : "database-vm-1",
			"UserName" : "ruth",
			"UserPassword" : "Supersecret123!!",
			"DisableSshPasswordAuthentication" : false
		},
		{
			"ConfigurationSetType": "NetworkConfiguration",
			"SubnetNames": [ "mysubnet" ],
			"StaticVirtualNetworkIPAddress": "10.10.0.7",
			"InputEndpoints": [],
			"PublicIPs": [],
			"StoredCertificateSettings": []
		}
	],
	"ProvisionGuestAgent": "true",
	"ResourceExtensionReferences": []
}

Bring Linux up to date

$ aptitude update && aptitude upgrade
$ aptitude install rsync
$ aptitude install mdadm lvm2 xfsprogs

Configure internal load balancer

Add-AzureAccount
Set-AzureSubscription -SubscriptionName "Trial Account" -SubscriptionId "deadbeef-7216-4aef-8394-fce57df325a3"
Select-AzureSubscription -SubscriptionName "Trial Account" -Default

Add-AzureInternalLoadBalancer -InternalLoadBalancerName database -ServiceName frontendcloudservice -SubnetName subnet123 -StaticVNetIPAddress 10.10.0.100

Get-AzureVM -ServiceName frontendcloudservice -Name pooler1 | Add-AzureEndpoint -Name "database" -LBSetName "database" -Protocol tcp -LocalPort 5432 -PublicPort 5432 -ProbePort 5432 -ProbeProtocol tcp -ProbeIntervalInSeconds 10 -InternalLoadBalancerName database | Update-AzureVM
{
"RoleName": "database-vm",
"RoleType": "PersistentVMRole",
"RoleSize": "A5",
"AvailabilitySetName" : "databases",
"OSVirtualHardDisk": {
"OS": "Linux",
"HostCaching": "ReadWrite",
"DiskName": "database-vm-disk",
"DiskLabel": "database-vm-disk",
"SourceImageName": "Debian-Wheezy-635506180993665396",
"RemoteSourceImageLink": "http://account.blob.core.windows.net/vmdepot-images/TE-2014-11-03-debianwheezy-os-2014-11-03.vhd",
"MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-disk.vhd"
},
"DataVirtualHardDisks" : [
{"HostCaching": "ReadOnly", "DiskLabel": "database-vm-data1", "Lun": "0", "LogicalDiskSizeInGB": "1023", "MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-data1.vhd"},
{"HostCaching": "ReadOnly", "DiskLabel": "database-vm-data2", "Lun": "1", "LogicalDiskSizeInGB": "1023", "MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-data2.vhd"},
{"HostCaching": "ReadOnly", "DiskLabel": "database-vm-xlog1", "Lun": "2", "LogicalDiskSizeInGB": "1023", "MediaLink" : "http://account.blob.core.windows.net/vmdepot-images/database-vm-xlog1.vhd"}
],
"ConfigurationSets": [
{
"ConfigurationSetType" : "LinuxProvisioningConfiguration",
"HostName" : "database-vm",
"UserName" : "ruth",
"UserPassword" : "Supersecret123!!",
"DisableSshPasswordAuthentication" : false
},
{
"ConfigurationSetType": "NetworkConfiguration",
"SubnetNames": [ "mysubnet" ],
"InputEndpoints": [],
"PublicIPs": [],
"StoredCertificateSettings": []
}
],
"ProvisionGuestAgent": "true",
"ResourceExtensionReferences": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment