Friday, 29 May 2015

Delete/Redeploy Azure Websites at specific times within a TeamCity and Octopus Deploy CI/CD pipeline

Problem

Many clients request that specific environments be only available certain times during a day.

This is often due to the high cost associated with keeping environments that are not in use.

The problem here can be divided into two.

1. How do we make the environment unavailable?
2. How do we make the environment available once more?

Microsoft will charge Azure services per compute time. Meaning that even if you stop your Azure Website it will still incur costs. This is the crux of the problem. It means that we have to deploy and delete the deployment of the Websites in order to minimise cost effectively.

Now if we have our project building, testing and deploying in a TeamCity and Octopus deploy pipeline. Ideally the Undeploy and Re-Deploy should be tunneled through the appropriate stage in the pipeline.

The reason why we should do this is to ensure that redeployment goes through the same processes as a normal deployment, and that environment states (such as version number, failed/passed) all have one source of truth - The CI/CD pipeline.

Monday, 4 May 2015

PowerShell from SourceTree as a custom action

Step 1:
Create a ps.bat file with one line:

start powershell

Save this file in an appropriate location. I saved mine to:
C:\CustomCommands