VS Code!

Ever since graduating from a Systems Admin role to DevOps one of the most frequently used tools in my toolbag is the text/code editor. Like many people I started on Notepad++ which by its own right is still a legitimately good editor. However working back and forth between Mac, Linux, and Windows desktop environments I gravitated towards Sublime Text and stayed there for a long time. I’ve recently begun studying for the MCSA Linux on Azure certification and have begun poking at Visual Studio more and in doing so discovered VS Code. VS code is a beautiful open source editor with a ton of plugins and a nice UI with excellent choices in syntax highlighting. Here’s some of the selling points that caused me to jump over to it:

 

  • Dark Themes
  • Cross Platform Support (Linux, Mac, and Windows)
  • options to add “code” to your path
  • automatic detection of files in a git repo and change tracking
  • useful diff screens
  • ability to launch terminal from within the editor window
  • Chef Support
  • Puppet Support
  • Powershell Support
  • Folder tree management
  • Syntax highlighting that’s helpful without being color vomit
  • Integrations with Azure WebApps PaaS
  • Key bindings for Vim, Sublime and other familiar editors

 

Here’s a Link to download VS Code: https://code.visualstudio.com/

 

 

Uploading Hyper-V VHDs to Azure

I recently had a project I was working on in which some inherited Azure VMs were missing the Azure agent and nobody knew the passwords for them. After a quick support call to MS it became apparent I would have to delete the VMs and preserve the disks, download disks, load into hyper-v and manually reset the password. In doing this I learned a few gotchas such as not being able to convert the VHD into a bootable Azure disk unless uploading through the Azure Powershell CLI. Here’s my quick how to upload disks guide.

Installing Azure Powershell

First we will need to install the Azure Powershell Module. This can be accomplished by running Powershell as administrator and entering the following:

Install-Module Azure

When prompted press choose A for yes to all. 

Note: If there is any conflict you may need to add the -AllowClobber to the end of the command above.

 

Login To Azure and Get Publish Settings File

First you will need to log into Azure by entering the following in Powershell

Add-AzureAccount

At this point you will be prompted to log into Azure. 

 

The next step will be to get an Azure Publishing Settings file. You can do this by entering the cmdlet below and then importing the file with the following cmdlet:

Get-AzurePublishSettingsFile

Import-AzurePublishSettingsFile -PublishSettingsFile “<path to file>”

 

Select Your Subscription and view Storage Accounts

At this step we will choose which subscription to use (if you have more than one) and list storage accounts so that we know where to upload the disks to. 

Warning: If you attempt to upload the VHD through the web GUI instead of using this method it will be created as a block blob not a page blob which prevents you from being able to convert it to a bootable disk for use in the gallery. The only way to do this correctly at the time of this writing is through the Powershell API.

Get-AzureSubscription

Select-AzureSubscription -SubscriptionId <enter yours here>

Get-AzureStorageAccount 

 

Uploading The Azure VHD and Converting It

At this point we are setup for the part we’ve all been waiting for. Make sure your VHD is not thin provisioned and that the VM has the Azure Agent installed and has been sys prepped (if using as a template).

Add-AzureVhd -LocalFilePath “<file path to your VHD>” -Destination “<URL of storage location with your filename after the last />”

This will create an MD5 hash and upload the disk. 

 

To convert the disk we will want to run the following:

Add-AzureDisk -Diskname ‘<name your disk something relevant>’ -MediaLocation ‘<URL where your disk lives in azure storage>’ -Label ‘<label>’ -OS <Choose Windows or Linux>

Atlassian Bamboo Server Github Issues

As any of you who have been using Atlassian’s cloud offering of Bamboo know, it is going EOL at the end of January 2017. The migration has reasonably decent instructions to follow, but my migration ran into a big road block when linked repositories failed when choosing Github as the repository host with a 403 forbidden. The 403 forbidden is actually in relation to a javascript error and not the actual reason that this is failing. Tailing the output of the catalina.out revealed the issue was actually related to cross site request forgery issues. The reason this was happening is that I had setup nginx as an https proxy on 443 that routes traffic to 8085 on Tomcat.

 

I found the following link that indicates the resolution is to insert the following into your server.xml file

proxyName="ci.example.com"
 proxyPort="443"
 scheme="https"

What was not terribly obvious in this documentation what what section this should go into. The section this should be placed in is the <Connector section within server.xml, see example below:

 

<Connector port="8085"
 maxThreads="150"
 minSpareThreads="25"
 maxSpareThreads="75"
 connectionTimeout="20000"
 enableLookups="false"
 maxHttpHeaderSize="8192"
 protocol="HTTP/1.1"
 useBodyEncodingForURI="true"
 redirectPort="8443"
 acceptCount="100"
 disableUploadTimeout="true"
 proxyName="ci.example.com"
 proxyPort="443"
 scheme="https"/>

Last but not least don’t forget to restart the service for this to take effect. Hopefully this saves you hours of headache in your migration!