'How to select a variable upon selection of another in arm templates?
I'm very new to ARM templates(like terraform than ARM but, I got no choice DevTest Labs doe snot support Terraform templates to read and deploy from a github repository). I'm trying to write a template to deploy a market place image which has two plans.
Image reference
"11.1": {
"publisher": "publisher",
"offer": "offer",
"sku": "SkuA",
"version": "latest"
},
"12.0": {
"publisher": "publisher",
"offer": "offer",
"sku": "skuB",
"version": "latest"
},
Plans
"plan11": {
"name": "nameA",
"publisher": "publisher",
"product": "Product"
},
"plan12": {
"name": "NameB",
"publisher": "publisher",
"product": "product"
}
I need to get only input from user on the image selection and based on that auto select the plan. how can I achieve this?
Thanks in advance
Solution 1:[1]
There is one great solution for your problem:
First you can specify parameter image like this:
"identityType": {
"type": "string",
"defaultValue": "None",
"metadata": {
"description": "Type of managed service identity. - SystemAssigned, UserAssigned, None."
}
}
Then in the section variable you can create all possible solutions like this - in your case plans with image:
"identityProperties": {
"None": {
"type": "None"
},
"SystemAssigned": {
"type": "SystemAssigned"
},
"UserAssigned": {
"type": "UserAssigned,SystemAssigned",
"userAssignedIdentities": {
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]": {}
}
}
}
Then the only thing remaining is to specify the parameter and the variable that goes with the value of the parameter:
"identity": "[variables('identityProperties')[parameters('identityType')]]"
Make sure to the name the variable values in my case None,SystemAssigned,UserAssigned same as the parameter value that you are providing
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kqly |
