5 Steps and under 30 minutes to deploy ARM Templates via Octopus Deploy

Octopus Deploy have been really up in the game of constantly adopting to the cloud Platform. Here is one of the example of deploy azure resource manager templates via octopus deploy. Authoring a resource manager template in visual studio, source control in Git based visual studio team services , build using the VSTS build system with the hosted agent and deploy the infrastructure via octopus deploy.

Pre-requisites

  1. Azure basic concepts
  2. Octopus Deploy
  3. Basic understand of JSON
  4. Visual Studio Team Systems
  5. Azure PowerShell

Here you go, the five steps

  1. Create the azure subscription and add accounts in octopus deploy.
  2. Author using visual studio and source control in VSTS
  3. Build and Package in VSTS
  4. Create Octopus Project and Configure variables
  5. Deploy and Test the template

Step 1

If you are a msdn subscriber then you will get free credits and you can create a azure account from www.azure.com or there is a pay as you go account available to use.

Note: When resources are not in use, always deallocate, delete the resource if not scale down. So your operational cost is less.

Add the subscription as account in Octopus as shown below

Step 2

we are going to author azure resource manager template to create the infrastructure to host the azure websites.

  1. Create a Resource group

    Use the available library to create the resource group https://library.octopusdeploy.com/step-template/actiontemplate-creates-an-azure-resource-group

  2. Create the azure resource group Deploy project in visual studio

    Follow this documentation, to get started https://azure.microsoft.com/en-gb/documentation/articles/resource-group-authoring-templates/

  3. Added the nuspec file to the deploy project

  4. This template belongs to the deploy project which is available in the visual studio. Which ends with the file extension .dproj.

    Sample snippet of the template

  5. You can find lot of azure quick start templates from this link https://github.com/Azure/azure-quickstart-templates
  6. Octopus Deploy preferred source is nuget package , so let’s add the nuspec file to package the template and the parameters file.
  7. Commit all the changes to the source control.

Step 3

Now we have the source code for our infrastructure in VSTS Git based source control which provides nice intergration with visual studio.

  1. Creating a new build definition to build and package the template available in source control,

    Create new build definition

    Update the build number format that a nuget package manager can accept

    Add the visual studio build step

    Choose the nuget packager step followed by nuget publisher step to publish the packages into vsts hosted package manager.

    Reference article.

  2. Now, queue the build to publish the package.

Step 4

  1. Create the octopus’s projects

  2. Create all the required variables in this case as shown below

  3. Add the step to create the resource group
  4. Add the step to deploy the azure resource manager templates

    Note: This steps will also replace the octopus variables defined in the parameters and template files before the deployment.

Step 5

Once all the variables are defined and scope , we are ready to create a release then deploy the infrastructure to the chosen Microsoft azure account. Login to the portal to check if the resource are available or use the azure PowerShell cmdlets to validate the existence of the new resources. Reference below

There are few key takeaways and be aware of

  1. First thing, check If you have appropriate version of azure PowerShell installed else use the https://github.com/OctopusDeploy/Library/pull/395
  2. Make sure the nuspec files section points to the correct build output directory
  3. When adding octopus variable double quotes for a string and just octopus variable for a integer type variables
  4. Choose the appropriate type of deployment you need it can be either one incremental or complete.
  5. You can use the same template for multi-tenant infrastructure provision as well. This will be detailed in the upcoming posts.

Hope you liked this article.

I’m always looking for feedback, please provide one so that I can provide with better content.

Have a great day !!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.