Azure Resource Manager : Deployment variants within one script

Introduction
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="https://kvaes.wordpress.com/2016/01/22/deploying-rancher-server-via-an-azure-resource-manager-template/”>server & nodes into one script.

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

Structure

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”: [
“Nodes”,
“Server”
],
“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”: “https://raw.githubusercontent.com/kvaes/azure-docker-rancher/master&#8221;,
“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”: “1.0.0.0”
},
“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!

TL;DR

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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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