Manageacloud

Azure: Create and Provision Windows Servers Automatically

The goal of this article is to explain how to create and configure a Windows server automatically using Azure and the cross platform command line interface (xplat-cli).

Getting Started with Windows Azure xplat-cli

1) Install the Windows Azure command line interface

npm install -g azure-cli

Do you need a Linux Terminal ?

Manageacloud provides free Linux terminals ready to use. We also have terminals with Azure xplat-cli pre-installed available.

Debian and nodejs

Unfortunately not all nodejs applications works on Debian based distributions out of the box. If you have problems with azure xplat-cli, try the following command:

ln -s /usr/bin/nodejs /usr/bin/nod

2) Activate the Service Manager Mode

azure config mode asm

3) Log into your Azure account

azure login

4) Create the network for the Windows VM

azure network vnet create --location "East US" testnet

5) Create the Windows VM

azure vm create --vm-name macdemotest --location "East US" --virtual-network-name testnet --rdp 3389  macdemotest   ad072bd3082149369c449ba5832401ae__Windows-Server-Remote-Desktop-Session-Host-on-Windows-Server-2012-R2-20150828-0350 username MySafePassword01!

Accessing to the Windows Server.

You can confirm that the server is ready to use by executing the following command:

azure vm list

Once the server is ready to use, you can access to the desktop using RDP. For Linux users, remmina is recommended.

6) Provision the Windows VM

As a proof of concept for the provisioning of the Windows server, we are going to create the folder C:\HelloWorld. The source code of the script is hosted in github.

azure vm extension set macdemotest CustomScriptExtension Microsoft.Compute 1.4 -i '{"fileUris":["https://gist.githubusercontent.com/tk421/11a2ec3fad5bcce5de3f/raw/b0ca8770100905a39b2dadd0fec7d159ccc73874/createFolder.ps1"], "commandToExecute": "powershell -ExecutionPolicy Unrestricted -file createFolder.ps1" }'

Automating server creation and provisioning

The goal is to create the windows server and provision it without any user input. To do that we will create the blueprint of the infrastructure by using a macfile.

Macfiles

A macfile contains the blueprint of the whole application, including the rules required to create, destroy and maintain environments through the lifecycle.

1 - Install Manageacloud Command Line Interface

curl -sSL https://manageacloud.com/mac | bash

Do you want all the software pre-installed ?

To make easier to try this post, we are offering free Linux terminals with Azure and Manageacloud CLI pre-installed.

2 - Register an user and login

mac login

3 - Save azure.macfile, the file that knows how to create and provision the windows server

curl https://gist.githubusercontent.com/tk421/5114ef86fbfc6b1e4d7c/raw/edd6a06385ac1232471ecc3ec6847b7f012c666d/azure.windows.creation.provisioning.macfile > azure.macfile

4 - Execute the macfile to create and provision the windows server

mac infrastructure macfile azure.macfile

5 - Destroy the infrastructure

mac infrastructure destroy azure_demo 1.1

Managing infrastructures

In this example the infrastructure consist in two resources: the network and the Windows server. Once the macfile is defined, both resources are associated, and you can create and destroy infrastructures easily.

Automation Services

Manageacloud can help you to automate your application within days. Contact us for more information.

Written by Ruben Rubio Rey on Monday October 19, 2015
Permalink - Tags: azure, xplat-cli

« Zero Downtime using Blue Green Deployments - Dockerising Puppet »