$ pwsh
$ PS> Connect-AzAccount
$ PS> New-AzResourceGroupDeployment -ResourceGroupName arm-grp -TemplateFile scripts/arm/arm-variable.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "",
"apiProfile": "",
"parameters": { },
"variables": { },
"functions": [ ],
"resources": [ ],
"outputs": { }
}
Other scripts can be found here.
Extract the id of that specific resource.
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'enrico-vn', 'subnet1')]"
"location": "[resourceGroup().location]",
"variables": {
"resourceLocation" : "North Europe"
},
"resources": [
{
"name": "storage",
"type": "Microsoft.Storage/storageAccounts",
"location":"[variables('resourceLocation')]",
}
If you do not pass at runtime the value(s), then default value is taken.
"parameters": {
"storage-sku": {
"type": "string",
"defaultValue":"Standard_LRS",
"allowedValues": [
"Standard_LRS","Standard_GRS","Standard_RAGRS"
]
}
},
"resources": [
{
...
"sku" :{
"name": "[parameters('storage-sku')]"
},
}
]
Complete file is here
You can either using Azure Portal o pass the parameter with another file:
$ PS> New-AzResourceGroupDeployment -ResourceGroupName az-104 -TemplateFile ./scripts/arm/arm-storage-with-parameters.json -TemplateParameterFile ./scripts/arm/parameter.json
"parameters": {
"vmpassowrd":{
"type": "securestring",
"metadata": {
"description": "Please type the password"
}
}
},
"resources": [
{
"name": "[concat('enricosa',copyIndex())]",
...
"copy": {
"name":"storagecopy",
"count": 3
}
}
]
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('MetworkSG'))]"
],
$ New-AzResourceGroupDeployment -ResourceGroupName az-104 -TemplateFile ./scripts/arm/arm-storage-account-with-parameters.json -TemplateParameterFile ./scripts/arm/params-sa.json
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-datacenter-gensecond",
"version": "latest"
},
offer/sku: :bangbang:
:bangbang:
$ az deployment group create --resource-group <resource-group-name> --template-file <path-to-template>