Azure Resource Management Templates

HI

What is the best practice to deploy Resource templates with linked templates, at present I use Team City to Upload them all to a private storage account and pass in the url + Sas token and issue the powershell command to deploy from that location.

I would like to use Octopus to manage the deployment of these so they everything is one location and make use of the environment variables and have the same pipeline that I have for my applications.

Do you have any plans to support this scenario ?

If not, how would I go about running getting the environment & project variables into each file in the package before I upload it using powershell ?

Hi Jonathan,

Thanks for getting in touch and sorry to keep you waiting. I am going to work with a colleague on this tomorrow and get back to you with an answer.

Speak soon!
Mike

Hi Mike

No problem at all, thanks !

Regards

Jonathan

Hi Jonathan,

I’ve had a few conversations about linked RM templates, here’s our current thinking, based mainly on the documentation here: https://azure.microsoft.com/en-us/documentation/articles/resource-group-linked-templates/

The main sticking point is, only your master template can be a local file, everything else must be accessible by http or https.

  1. Make a My_project_resources_template.json which acts as the master template:
    a) It links to all the other templates by HTTP/HTTPS URI
    b) It provides a parameters file which you can fill using Octopus binding statements, and then pass those values to the linked templates
    c) It collects output parameters from the linked templates, and passes those as necessary into other linked templates
    d) Put that master template in the package used by the Octopus ARM step
  2. Put all of your linked templates somewhere publicly accessible, like a GitHub repo where you control revisions to those templates. (If you can’t expose them that way, continuing with the Storage Account -> Container -> SAS keys is perhaps the best option)

We were thinking about ideas where you could package all your linked templates and write local references into the master template, then Octopus would upload them automatically to a storage account, and rewrite the links on your behalf… This sounds a bit magical and could be surprising, but perhaps you have a different opinion/perspective.

I think if your linked templates are more “generic” in nature, not tied to a specific project/situation, putting your linked templates in a shared location is a good idea.

What do you think?

Hope that helps!
Mike

HI Mike

Thanks for the response, i would not be comfortable hosting the templates on something that would be publicly available, the best option would be to upload to my own storage account and pass in the the URI to the template before its executed.

I would ensure all parameters are passed along the chain of templates and this is the probably the way to go, as I can keep the build pipeline the same as the pipeline used for our apps and services.

It would however be useful to be able to run variable transform across all files in the package and the use powershell to upload to my storage account, then simple deploy the template from there.

Is it possible to run a transform as a process ?

R

Jonathan

Hi Jonathan,

Sounds like a good way to go. Regarding the variable transforms, you have a few options available to you.

  1. You can use a single master parameters file, using the built-in Azure Resource Manager Step features to set those values using the Octopus Binding Syntax #{}, and then pass those parameters through to your linked templates.
  2. If you need to update sections of the linked templates, you could enable the Substitute Variables In Files feature, specifying the files you want to perform substitution upon.

Is that what you were meaning?

Hope that helps!
Mike

HI Mike

I have a good working solution, its just took a few days to work it through, I intend to write up a blog post giving the complete solution and link here (if that is OK). But in a nutshell

  1. Create the ARM nuget template package in TeamCity
  2. Use a Deploy Package Process on a single tentacle
  3. Include a post deploy powershell script to upload the the contents
  4. I can need to a variable transformation on all of my files (not actually needed)
  5. Run a script to Obtain a SAS access token and the use to the base directory of the uploaded files , and put these into Output variables
  6. Create a Resource Group
  7. Deploy the ARM template making use the the output variables from early to link templates.

This works a charm,

Thanks for all the help Mike I appreciate the time !

R

Jonathan

Hi Jonathan,

Same to you too! Just food for thought, but perhaps this might make a good
addition to the Octopus Library?

https://library.octopusdeploy.com

Looking forward to your blog post!
Mike

Hi Mike

I can get it work as library component I certainly will, I have only been using OD for 3 weeks now (I am still in my trail period) so not sure my skill level has gotten that high yet :slight_smile:

I will write up my post and then you can let me know if its possible

R

Jonathan