Professional Documents
Culture Documents
MENU
☰
"parameters": {
"<parameter-name>" : {
"type" : "<type-of-parameter-value>",
"defaultValue": "<default-value-of-parameter>",
"allowedValues": [ "<array-of-allowed-values>" ],
"minValue": <minimum-value-for-int>,
"maxValue": <maximum-value-for-int>,
"minLength": <minimum-length-for-string-or-array>,
"maxLength": <maximum-length-for-string-or-array-parameters>,
"metadata": {
Using Parameters
To use the Parameters we would use the same example referred in creating basic arm template
which is here
To Start with we have the following structure of arm template
"$schema": "https://schema.management.azure.com/schemas/2015-01-
01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [{
"name": "myVirtualNetwork",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-08-01",
"tags": {
"Reason" : "Learning"
},
"properties":{
"addressSpace": {
"addressPrefixes":[ "10.1.0.0/16"]
},
From the syntax section if i have to write the basic structure for virtual network name. It would be
like "networkName":{
"type": "string",
"defaultValue": "myVirtualNetwork",
"metadata": {
"description": "virtual networks name"
}
}
similarly the subnet name can be written as "subnetName":{
"type": "string",
"defaultValue": "myVirtualSubnet",
"metadata": {
"description": "Subnet's name"
}
}
add the above two steps snippets to your template
"$schema": "https://schema.management.azure.com/schemas/2015-01-
01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"networkName":{
"type": "string",
"defaultValue": "myVirtualNetwork",
"metadata": {
},
"subnetName":{
https://directdevops.blog/2019/01/24/azure-resource-manager-parameters/ 1/3
1/20/22, 11:17 PM Azure Resource Manager Parameters – Direct DevOps from Quality Thought
"type": "string",
"defaultValue": "myVirtualSubnet",
"metadata": {
Now in the resources section we need to remove the hardcoded names of network & subnet with
parameters. For that we need to use specific function called parameters as describe over here script
would look as
"$schema": "https://schema.management.azure.com/schemas/2015-01-
01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"networkName":{
"type": "string",
"defaultValue": "myVirtualNetwork",
"metadata": {
},
"subnetName":{
"type": "string",
"defaultValue": "myVirtualSubnet",
"metadata": {
In the same manner i would like to parametrize the address space array for the network & address
space string for subnet. The script will be change to as shown below
"$schema": "https://schema.management.azure.com/schemas/2015-01-
01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"networkName":{
"type": "string",
"defaultValue": "myVirtualNetwork",
"metadata": {
},
"subnetName":{
"type": "string",
"defaultValue": "myVirtualSubnet",
"metadata": {
Lets execute this deployment. I would be using CLI to create this deployment. Refer here
Since we have added parameters, lets change the values of parameters during deployment
execution
Lets create a file which consists of all the values of parameters to be passed. I have decided to pass
the following
For this i would build a json file containing all of my parameters. I would need to consider types as
well Basic structure of the parameters file is
"$schema": "https://schema.management.azure.com/schemas/2015-01-
01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"<parameter-name>": {
"value": <parameter-value>
If we would create parameters file with name parameters.json for our purpose it would look like
"$schema": "https://schema.management.azure.com/schemas/2015-01-
01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"networkName": {
"value": "myNewNetwork"
},
"subnetName": {
"value":"myNewSubnet"
},
"networkAddressSpaces": {
"value":["192.168.0.0/16"]
},
https://directdevops.blog/2019/01/24/azure-resource-manager-parameters/ 2/3
1/20/22, 11:17 PM Azure Resource Manager Parameters – Direct DevOps from Quality Thought
"subnetAddressSpace": {
"value":"192.168.0.0/24"
Lets execute this deployment with parameters file . I would be using CLI to create this deployment. Refer here
azyp99 says:
January 25, 2019 at 7:20 pm
Loading...
Reply
Leave a Reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
PREVIOUS POST
NEXT POST
Terraform Backends
POWERED BY WORDPRESS.COM.
https://directdevops.blog/2019/01/24/azure-resource-manager-parameters/ 3/3