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.
- Azure basic concepts
- Octopus Deploy
- Basic understand of JSON
- Visual Studio Team Systems
- Azure PowerShell
Here you go, the five steps
- Create the azure subscription and add accounts in octopus deploy.
- Author using visual studio and source control in VSTS
- Build and Package in VSTS
- Create Octopus Project and Configure variables
- Deploy and Test the template
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
we are going to author azure resource manager template to create the infrastructure to host the azure websites.
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
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/
Added the nuspec file to the deploy project
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
- You can find lot of azure quick start templates from this link https://github.com/Azure/azure-quickstart-templates
- Octopus Deploy preferred source is nuget package , so let’s add the nuspec file to package the template and the parameters file.
- Commit all the changes to the source control.
Now we have the source code for our infrastructure in VSTS Git based source control which provides nice intergration with visual studio.
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.
- Now, queue the build to publish the package.
Create the octopus’s projects
Create all the required variables in this case as shown below
- Add the step to create the resource group
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.
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
- First thing, check If you have appropriate version of azure PowerShell installed else use the https://github.com/OctopusDeploy/Library/pull/395
- Make sure the nuspec files section points to the correct build output directory
- When adding octopus variable double quotes for a string and just octopus variable for a integer type variables
- Choose the appropriate type of deployment you need it can be either one incremental or complete.
- 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 !!!