Azure Resource Manager : Deployment variants within one script

Today a quick post to show you that you can setup a deployment with several variants within the current template functions.
So for this post we’ll be combining the deploment for the rancher <a href="”>server & nodes into one script.

2016-02-19 10_53_14-Parameters - Microsoft Azure


The “azuredeploy.json” will be our entry template. Here we’ll capture the parameters and launch the template to either create the server (azuredeploy.server.json) or the nodes (azuredeploy.nodes.json)

2016-02-19 10_44_14-azure-docker-rancher

Entry Template
So how do we handle this in the entry template? First of all I’ve added a parameter as a way to select what option you want…

“deploymentType”: {
“type”: “string”,
“defaultValue”: “Nodes”,
“allowedValues”: [
“metadata”: {
“description”: “Choose if you want to add nodes to an existing server or deploy a server without any nodes.”

And a link to the base of the template sources, as we’ll be using this to find the additional scripts ;

“templateBase”: {
“type”: “string”,
“defaultValue”: “;,
“metadata”: {
“description”: “Change this value to your repo name if deploying from a fork”

These parameters will be used in the variables to generate the script location of the deployment that needs to be launched.

“variables”: {
“apiVersion”: “2015-11-01”,
“deployTypeParam”: {
“Nodes”: “azuredeploy.nodes.json”,
“Server”: “azuredeploy.server.json”
“deployTypeParamValue”: “[variables(‘deployTypeParam’)[parameters(‘deploymentType’)]]”,
“templateBaseUrl”: “[concat(parameters(‘templateBase’), ‘/’)]”,
“templateDeployUrl”: “[concat(variables(‘templateBaseUrl’), variables(‘deployTypeParamValue’))]”

With the newly generated “templateDeployUrl” variables, we’ll be launching the deployment;

“resources”: [
“name”: “rancherdeploy”,
“type”: “Microsoft.Resources/deployments”,
“apiVersion”: “[variables(‘apiVersion’)]”,
“properties”: {
“mode”: “Incremental”,
“templateLink”: {
“uri”: “[variables(‘templateDeployUrl’)]”,
“contentVersion”: “”
“parameters”: {
“adminUsername”: {
“value”: “[parameters(‘adminUsername’)]”
“adminPassword”: {
“value”: “[parameters(‘adminPassword’)]”
“rancherApi”: {
“value”: “[parameters(‘nodesApi’)]”
“rancherNodeName”: {
“value”: “[parameters(‘deployPrefix’)]”
“rancherVmSize”: {
“value”: “[parameters(‘vmSize’)]”
“rancherCount”: {
“value”: “[parameters(‘nodesCount’)]”

Where you can see we’ve also added the parameter list as expected. One sidenote here… The parameter list needs to be the same for both scripts!


  • Today we learned that we can deploy variants from within one script.
  • The approach is limited…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s