As regular readers will know I really like the tools provided by Hashicorpβ†— and today I found an excuse to use one. I needed to bring up a Virtual Machine in Microsoft Azureβ†— . I hadn’t logged into Azure for quite a while so imagine my shock when I opened the dashboard, it’s not that great and the beta of the new one isn’t that brilliant either. It was so bad I tweeted about it ….

I had recently looked at Terraform↗ for another project and I worked through the excellent getting started guide which covers how to launch AWS Instances↗ .

I decided that it maybe more straight forward to launch my test Virtual Machines using Terraform rather than going through the dashboard, apart from the storage container which I created ahead of launching my configuration.

Terraform is straight forward to install if you have Homebrew↗ installed, none Mac users can follow the install guide↗ .

Terraform & Azure 1/6
bbrreewwicnasstkalilnsttearlrlafgorramphviz

There is a Cask version of terraform, this does not ship with the Azure provider so use the main brew package instead. Graphviz↗ is installed so that the graph functionality can be used.

I downloaded a copy of my Publish Settings from https://manage.windowsazure.com/publishsettings↗ and renamed the file to settings.publishsettings. I then created terraform configuration (which can be found in the following repo https://github.com/russmckendrick/terraform-examples/tree/master/azure↗ ).

First off I checked everything was OK with the configuration using terraform plan;

Terraform & Azure 2/6
RTN++P⚑vDEehRwewoβ€œddellnsuadeeeeehcilnpssssuvlaenfeeixitaaeepaoatrauennnnnoopoaaeitusiatrftrslilepzfshbcmalztsdddddsv_cmsczobepne.aeeTolsl:puaceeaet:uocpppppteiaaesuernr_:raurseutlrurmlt:urmroooooermdt:wr:aenarzlhrrbsbYyelie:isβ€œeaiiiiiid:adioigtad2autairce)eo”_tproβ€œ:”_tpnnnnn_groβ€œrtβ€œe:mdfr:nae,uh_taβ€œn”iittttttseen”dy”_ertoevgfscdiocil”:β€œ=nci.....e:s::_sβ€œ:eor_saoryedsseo_=”>s_o#2222rs=g=e”smselTraeesitrnc=β€œ>tun:4444vβ€œ:β€œ>β€œr>rβ€œsaetuemraltdcet:o>”=β€œap:6666i”””ov=”:dptteretlrnadinβ€œ><ndβ€œ2222cβ€œβ€œuβ€œi>dlti:reeoo’l_fβ€œtβ€œ=rccaβ€œβ€8888e=”=r=pBc=β€œ,ainaxsdwytlsi”er>uβ€œoet”1111_>>u>:aeβ€œ>”nngfeheeecnus<m.e=7777n=ss_<0gsocordsdra=tsβ€œscpbs=>7777aβ€œ>β€œsβ€œβ€œincβ€œ=s.ruwoe.p,vt>ssW-oua:>8888mOW-z”caoa>t_pmtnrseie:-etmtsβ€œ2222epβ€œet6_mmzofuiocTc_β€œtsepeiβ€œβ€œ1....:e<se9=Aepuβ€œibsoiduieetHβ€œftrudc”<”npppnctrr>1:ur<clltnnerfr.ho”-rt>-carruβ€œLorV”techeiascyrtushEae”s=omiob”omEaZβ€œβ€œeuoastpateaemt=sufde>mevtlgpuff<”dsmnhellrsafrbe>-ro>rp:aoi=iuroHc>epgsaponorpd0or”vβ€œutcc>ctor”o=”rueepnhyararβ€œ1pme0tβ€œeo_epmm>”t,traerβ€œmfis0”e-r”e”_lpβ€œ7de-petihbde-one””sdp:or.>”tuβ€œd0ioaeocrtre>=oru1”etr>nrstabuam:vr”>rβ€œts”seu”tginetn-ivt”:stdsostbcdi”’sβ€œciβ€œ:-”>soeante”ecS=β€œt”sdeltgpreSβ€œ>”etepnhagv=c”H”rosloecrui>rβ€β€œ=rrtagrnhaace=t>aernedamreβ€œa>cfao…necnea<tpβ€œogyerrgtnceβ€œβ€2re.reeetod22m”afadrem2”-totepb”sereituyeddnottrq-heTvauipsideiniflas>rcdcav”rekaceia”inesfss,tocehwrsaxaihmhninsa.onsdt”witpnnirlwgneaib.gdnle,llGrroreesewessox.eooenuuwcrrhurcceteeeness.ources

As you can see everything is good to go, I also generated graphical overview using terraform graph which shows how it looks;

Terraform & Azure 3/6
terraformgraph|dot-Tpng>graph.png

graph

As everything looked good it was time to apply the configuration and launch the Virtual Machine using terraform apply;

Terraform & Azure 4/6
aATS⚑vDEzddellnsuaaadeeeeehcilnpssssuvaphbiutaenueepaoatrzzuennnnnoopoaaeitusizpeensatrftrfshbcmaluutsdddddsv_cmsczobepullfete.aeeaceeaet:rrocpppppteiaaesuernr_rysoreraur_urmlt:ueemroooooermdt:wr:aenaetwatrzlhlie:isβ€œ__aiiiiiid:adioigtad_ca.shpautaotproβ€œ:”hitpnnnnn_groβ€œrtβ€œe:mdiotteafr:s_taβ€œn”onittttttseen”dy”_ernmeTrtoevtcil”:β€œ=ssci.....e:s::_sβ€œ:esphu`hr_saeeo_=”>tt_o#2222rs=g=e”stloict:mseldrnc=β€œ>eaun:4444vβ€œ:β€œ>β€œr>rβ€œsaefsteetu_t:o>”=β€œdnp:6666i”””ov=”:nturtattesinβ€œ><_cdβ€œ2222cβ€œβ€œuβ€œi>ceysrrepti:efβ€œtβ€œ=rcseaβ€œβ€8888e=”=r=pBc=β€œe!otearpinri”er>uβ€œoe.t”1111_>>u>:aeβ€œ>”.ua,frlngvcnus<mrbe=7777n=ss_<bRrtoaygsia=tsβ€œscpvas=>7777aβ€œ>β€œsβ€œβ€œincβ€œ=aeesrfs.ct>ssW-ouis:>8888mOW-z”caoa>ssiomo_pee:-etmtciβ€œ2222epβ€œet6_mmzionirfu._β€œtsepeecβ€œβ€œ1....:e<se9=Aepuβ€œcufsksmibttHβ€œftrud.-”<”npppnctrr>1:ur<-rreh.lleho”-rt>tscarruβ€œLorV”tecscareoteirushEae”ee=omiob”omEaZβ€œβ€œeuoeesepwfsrmt=sufdrr>mevtlgpuff<”dsmrstq`shabe>-ro>rvp:aoi=iuroHc>epv:ruitsfpd0or”aeβ€œutcc>ctor”o=”rueuitcaeorβ€œ1pmfr0tβ€œeo_epmm>”tr2crottris0”e-o:”e”_lpβ€œ7de-pe:tesmetmne””srdp:or.>”tuβ€œdaudami-tremC>=oru1”etr>Cdrfans:vr-r”>rβ€œts”seu”rdetengeivset”:stdseeo.dsrβ€œcieaβ€œ:-”>sadh.v”ecrtS=β€œt”st,amTieviSβ€œ>”etisooc=c”inH”roo0de>rcgβ€β€œ=rrnbii:ee…=t>aecefnβ€œa:>cfacheysC<tpβ€œogoanprceCβ€œβ€2remnaeeodr22m”pgsncame2”-leadttpba”sedviuytet,edtntiredehgeTov0se…denitt>rcdorc”rceeooao”stymfmthpopreylrlooemeyput.teare”edt.hstate

As you can see from the GUI below it launched the Cloud Service and Virtual Machine as defined.

microsoft-azure

I then used terraform show to query my instance to get the computed elements of the configuration;

Terraform & Azure 5/6
⚑aidellnaiaeeeeehiilnprssssuvzdepaoazdunnnnnompoaaeeitusitushbcmutdddddsa_cmsvczobeper=ceeaer=oppppptgaaeseuernr_rermltemoooooeedtwrraenar_riei=_raiiiiiddi=osi=gtadahupr=oiutnnnnn_=roretemdfostanrnsitttttsenrd_yB_=erossilrussc.....eOsud_asert-o_u=st-_#2222rps=s=ngse=smetncssatu4444vessrirsdeosW-nep=6666in=W-zocvas_r=n-etcrd2222cLet6=u_iz=hsrttseera18888eo1se9pAcuoeaHeftr.at1111_g0trr1er1wrfon-rbfe7777ni0rV=_e0vosthEaaos7777ac.EaZnu4irtssufsr8888m1uffas.cme-roim=2222e71roHme4e-d=0orc-.....2orer0.s1pm-tfnppp=1.pm.tesfe-seaarru3e-=2ereaseslmiobr2t1rvrlertsevtlu.er1rivsrveaois2su.acieve=tccs7ts1fecireo_-s2oec:S_lpts7reSpoetmcHo=rro-rrtrrsettaeeac=fart=pogve2reid22mc2-ebs:yerTveircreaform.

I connected to the Virtual Machine, did what I had to do (thats a whole other blog post) and then finally tore down the Virtual Machine and Cloud Service using terraform destroy;

Terraform & Azure 6/6
EvaA⚑DTTnaDEzaaaaapoehtrenuzzzzzptree.ftruuuuuleyrrraaeerrrrryroaezur_eeeeerufaulh_____caoirtaoiiihhofrrsve:snnnoomoema_vtssssspranlssaetttttlmlwoueeldaaaeeeliettu_nnnddtdylu:ttesccc__eelnii:eeeess!swdynnr...eetadoeggvbbbrrRrne.sssiaaavveotl_.csssiisyeOfpeiiiccottniu.ccceeuoellbt---..ryelesssttcdaireeeeeeelβ€˜srrrrrrsslyhavvvrr:tesfeeeaaryseorrrff0oo’tr:::ooyutmrra?rwi-RDDmmdinseee--dmlgefssssealsrrtteednverrrr,abisouvvgechycii0eeiitccda:nnieeccggo::hicR…naneesDDnfpftceegrtraosseaeetmttdsdseprr,th…lourtieyc2uon(titcgIenidtcDgoeuos:…nsrnttefarcr.ituooresmym…spe.-ld(te.IetDre:rarfuosrsm--tteersrta)form-service)

As a Mac / Linux user I found the whole experience to be a lot more what I am used to with other cloud services and a lot less β€œMicrosoft” than I feared.