Showing posts from 2017

Renaming files with Find on Unix

A quick handy hint for Unix command line users today - I had a lot of files to rename, spread through a file system. Sort of like this: The files were all named the same thing, but were in a whole lot of directories - I needed to rename each site-data.json file to just be data.json. I also had a bunch of other files that I wanted to leave alone - I didn't want to rename everything. I have done this sort of thing before, but every time I do I have to search again. I found lots of StackOverflow posts that didn't quite do what I wanted - which is: Find is an incredibly useful tool, and can look for names matching a pattern or word (site-data.json here) then pass that full file name to another command via the -exec option. The full path of the file is kept in {} - so that rename command applies the Perl regular expression (s/site-//g) to the full file name, and this chops off the site- prefix. It only affects the files I wanted to remain (they were the only things found

Setup a Kubernetes Cluster on Azure

Photo by  Joseph Barrientos  on  Unsplash I finally received my copy of Kubernetes: Up and Running by Kelsey Hightower  (put on pre-order more than a year ago!), and want to set up a Kubernetes cluster to experiment with.  I'm going to use Microsoft's Azure Container Service, but I want to set this up programmatically.  This will let me set up and tear down the cluster whenever I want to, and make sure that it's configuration doesn't drift over time.  This gives me confidence that I can recreate the cluster in exactly the same way later on, if I need to - if I want to move to a different region or resource group or whatever.  This also fits with the DevOps Infrastructure As Code philosophy, allowing you to check your resource scripts into source control and treat them the same as the code that's running on them. There are a couple of prerequisites I need to set up before I get started.  Firstly - I've just talked about versioning the setup, so I need to

Setting VSTS variables from PowerShell

Snapshot of my Environment Tear-up Release Phase I was using a VSTS release pipeline to build an Azure environment today with ARM Templates, and needed to set up a secure connection from a Web App to a Blob Storage account so the app could write logs. As with a lot of things in ARM, you can set up the connection and grab the template, but then you end up having a fixed access URL (SAS URL, or Shared Access Signature) in your JSON file: This is bad from a portability and security point of view, as the URL only gives access to one named account, but if you have that URL you can write whatever you want to storage. This URL will also expire in around a year's time - which will mean your site suddenly stops working like it used to!  That'll be an fun and interesting day. Fortunately its easy to create a SAS URL and pass it to a script as a parameter.  This PowerShell will create the access token: $rg = "my-storage-resource-group" $name = "mystorageacc

Feature Toggles on a .Net Core API

This is my second tutorial on feature toggling.  You can read the first here . There are many languages and frameworks to choose from when it comes to back ends - I wanted to make a REST service to deliver all of the Time Entries to my Angular application, and almost every language available has REST server capabilities.  I chose to use .Net Core (C#) and Java for my example app.  My background is in Java, and I was really interested to see how .Net Core works.  If you don't know, .Net Core is Microsoft's cross platform offering - it has the Windows-specific parts taken out and runs on Docker. Linux, MacOSX, and of course Windows too.  It can also be compiled on other platforms too, which is very handy. Today I'll be setting up LaunchDarkly using the .Net libraries - I'll do the Java version later on.  LaunchDarkly provides some samples  to help you get started, but I wanted to change a few things.  Just like I did in the Angular front end, I wanted to use a type to

Feature Toggles for Angular UIs

I had a chance to demonstrate a feature toggling library to a customer last week, and wanted to share what I did.  Feature toggles, in case you don't know, let you to configure how your system behaves without redeploying code.  This is fantastic if you have a feature that needs to launch at a particular time, or you want to experiment with by switching off and on in different environments.  Feature toggles act like an if statement around a code of block and can be switched on or off as desired, without requiring a restart.  Martin Fowler covers this in some detail  here . Filling out my timesheet is one of the least favourite parts of my week, but I thought I would build a simple timesheeting system for my demo.  I have a UI written in Angular using the Angular Seed  project and the Angular Material components.  The basic UI looks like this: I am working on a couple of features that aren't quite ready yet - being able to add and remove time entries, and to look up projec

Automatically Logging PowerShell in to Azure

I've been working with Azure Resource Manager templates a lot lately, as an easy, repeatable way to create deployment environments for my code.  ARM templates are a JSON description of a resource or grouping of resources and can be applied to create or update an environment.  This means you can roll out a new environment quickly and easily - perfect for quickly setting up a Dev or Test system, and you know that if you use the same templates to configure Production you won't have any surprises, or "Well, it worked in Dev..." conversations. The best thing about ARM templates for me is how easy it is to generate them.  If you have a resource group, you can create a template by clicking on the Automation Script button: This will create a show you a JSON template and supporting files that can be downloaded as a Zip.  It contains all the information needed to reproduce your resource group's infrastructure.  It isn't a backup though - it doesn't have the we

Adding personas to work items in VSTS

During the week I finished adding the requirements I started in  my previous post .  I found I needed a few more features - one about Security and one covering setting up the development projects and builds.  I also discovered an extension for VSTS that will help me keep focused on the users while I work. VSTS has a marketplace where you can see all the extensions and install those you think are useful. The one I will install is  Personas , by  Agile Extensions . They make a few VSTS extensions all aimed at making agile development more fun.  Personas is especially helpful for my project, as I don't have a source of real requirements or users, and using personas will help me turn user roles into real personalities. To get started select the Extensions button and Browse the Marketplace: The Marketplace has a large number of plugins and extensions, covering all sorts of functionality.  It's always interesting to look through and see what might be useful for your pr

Setting up Requirements in VSTS

Last week I started a new project with VSTS , setting up some Git repos for my code.  Now it's time to set up some requirements and planning for the development.  I chose to set up an Agile project last week, which is one of 3 default project types in VSTS.  This affects a number of things, including the form the requirements take and the development process used.  Agile is the most flexible, and is the one that I use most often.  Requirements are added to a project as Work Items: Agile Process Work Item Types - from the Microsoft documentation Most of my requirements will take the form of User stories, a common Agile construct.  These stories express a requirement in terms of a Persona, performing some Action to achieve a Result.  When you use this format you tend to drill down on the requirement, writing it in a format that's easy to understand and to develop.  Features are a piece of functionality that you want to deliver, and can be used to group stories together, wh

Setting up a new VSTS project

Visual Studio Team Services (VSTS) is an Application Lifecycle Management tool - it handles the whole lifecycle of software development from idea to requirements, planning, development, code reviews, build and release.  It is designed to support your team no matter what methodologies or languages you use.  While most users pay for a license or use their MSDN subscriptions to log in, Microsoft make VSTS freely available for teams of up to 5 users.  I am going to use my free account to plan and develop a new project, and share some tips along the way. Start off at  where you can sign up for a free account.  After you choose your account name, you can create a new project: Choose a Git repository to save your source code, and select the Agile work item process.  This process works well with most Agile methodologies without constraining you to a particular Scrum template.  When you press Create you'll be taken to the new project's dashboard.  It has a l

Changing Columns on a VSTS Sprint Board

It's very easy to add columns to a Product Backlog Board in VSTS - you can use the board settings to create new columns, rename and re-order, or even remove columns from the board.  The only special columns are the first and the last one, which can't be removed or deleted since they have a special meaning as far as work goes - they represent the start and end state of the work you're managing. It's more tricky to add columns to a sprint view, though - but this is really useful as it lets you customize the tool to your own workflow and preferences.  You have to be an administrator for the VSTS installation to do this, though - I'll show you how using one of my demo projects. Use the main config menu (the cog wheel) and click on the Process from the Overview tab: My project is an "Agile" project – it uses the Agile template.  From Process you can clone your current process and make your own.  Unfortunately you can't change the proces

Migrating SVN to Git with Branches

In my previous post  I did a simple migration of a Subversion project to Git.  I didn't want to keep any branches or history so purposely got rid of the history - it was more of a copy than a proper migration.  This time I will show you how to pull across some branches, and check that your commit history survives. Instead of starting with an export of the SVN project, we can use a Git tool designed for Subversion.  Run this command to tell Git where your SVN repo is, and a little about its structure: git svn init ↩ --prefix svn/ -T trunk --b=branch --t=tag Initialized empty Git repository in C:/tmp/Project/.git/ My repository had slightly odd names for the branches and tags folders so I had to use the --b and --t flags tell Git what where to look.  Next you can associate any Subversion accounts with the new Git logins.  To do this, create an authors.txt file, formatted like this: svn_username = Git User <>

Migrating from Subversion to Git

I've been helping a company move its source code from Subversion to Git recently to support their Agile transition. They're moving their build, issue tracking and code repos to Visual Studio Team Services (VSTS). This is the cloud-hosted version of Microsoft's Team Foundation Services, with built in Git hosting, build tasks and a Jira-like issue tracking system. I really like it, plus it's free for teams of 5 or less, making it perfect for my development needs at home. Check it out at  Most of my customer's projects don't need to keep their Subversion history - unfortunately they had no policy for commenting commits and most check-ins have empty messages so aren't of much use. The teams have made a conscious decision to abandon the past and drop the history. We will keep the old SVN repos alive for a while so if we really need to we can look back at changes, but don't expect to use it much. The simplest way to migrate these proj

Starting IoT with Raspberry Pi

This is the first in a series of posts where I get a Raspberry Pi connected to the Internet, and able to respond to commands from a web page.  I also want to get information off the Pi, so I can use the Pi to monitor things.  I am new to Raspberry Pi and the Python programming language, but have experience with programming and electronics.  If this works out well, I'd really like to do something with making an Arduino Uno talk to the Internet. First up I set up the simple circuit I'm planning on starting with.  Raspberry Pis don't have any analogue inputs, so I decided to use a switch for input and to turn on and off an LED as an output. The green wire connects the switch to IO port #4 on the Pi, while the blue wire connects the LED to port #5.  There's a 100Ω resistor to prevent too much current going through the LED and I put a 10kΩ resistor on the switch to pull the voltage down when the switch is turned off. The simple circuit I booted up my Pi with the late