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 ?
The main sticking point is, only your master template can be a local file, everything else must be accessible by http or https.
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
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.
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.
Sounds like a good way to go. Regarding the variable transforms, you have a few options available to you.
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.
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.
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
Create the ARM nuget template package in TeamCity
Use a Deploy Package Process on a single tentacle
Include a post deploy powershell script to upload the the contents
I can need to a variable transformation on all of my files (not actually needed)
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
Create a Resource Group
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 !
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
I will write up my post and then you can let me know if its possible