Skip to content

Instantly share code, notes, and snippets.

@tk421 tk421/azure.macfile
Last active Oct 19, 2015

What would you like to do?
Create and provision Windows Servers Automatically
# Create and provision Windows Servers Automatically
# You need azure xplat-cli installed and logged in before running this macfile
mac: 0.9.19
description: Azure Example
name: azure_demo # Infrastructure name
version: 1.1 # Infrastructure version
# Actions execute tasks which does not create resources in the cloud
# This action trigers a proof of concept of powershell bootstrap creating the C:\HelloWorld folder.
# The powershell script is stored here
bash: >
azure vm extension set macdemotest CustomScriptExtension Microsoft.Compute 1.4 -i '{"fileUris":[""], "commandToExecute": "powershell -ExecutionPolicy Unrestricted -file createFolder.ps1" }' --json
# This actions waits until the server that we are creating is ReadyRole
bash: >
while ! azure vm list | grep macdemotest | grep ReadyRole ; do echo "Waiting"; sleep 10; done;
# Macfile resources are tasks that creates items in the cloud (and it can also be destroyed)
# The VMs are create in a network.
# we specify how the network is created. The parameters are defined in "infrastructures" section.
create bash:
azure network vnet create --location "infrastructure.param.location" --json
# we specify how the network is destroyed. The parameters are defined in "infrastructures" section.
destroy bash:
azure network vnet delete -q --json
# This resource creates a Windows VM
create bash:
azure vm create --vm-name
--location "infrastructure.param.location"
--virtual-network-name infrastructure.param.virtual-network-name
--rdp 3389
infrastructure.param.image infrastructure.param.username infrastructure.param.password
destroy bash:
azure vm delete -q --json
# Infrastructures is the section that actually creates items in the cloud.
# The order is preserved.
# First of all creates the network. It is a dependency for the VM.
resource: network
location: "East US"
name: testnet
# Creation of the Windows VM
resource: windows_vm
name: macdemotest
location: "East US"
virtual-network-name: testnet
image: ad072bd3082149369c449ba5832401ae__Windows-Server-Remote-Desktop-Session-Host-on-Windows-Server-2012-R2-20150828-0350
username: username
password: MySafePassword01!
# We wait until the Windows VM is ready
action: wait_for_windows
# We Trigger the configuration of the VM.
action: provision_windows_1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.