PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 27, 2022

[FIXED] When should we use a parameter when to use variable in ARM templates

 September 27, 2022     azure, azure-resource-group, azure-resource-manager, azure-template, continuous-deployment     No comments   

Issue

I am confused about where to use a variable and where to use a parameter in ARM templates. How do we make this call ?

The referenced script uses both. I am more curious of the justification of using variables.

enter image description here

Reference

Sample Service Fabric Azure Deploy Script

https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/service-fabric-oms/azuredeploy.json


Solution

In the Azure template json file:

parameters:Values that are provided when deployment is executed to customize resource deployment.

variables:Values that are used as JSON fragments in the template to simplify template language expressions.

More information please refer to this official document:Understand the structure and syntax of Azure Resource Manager templates.

I am more curious of the justification of using variables.

Based on my experience, if you only use the variable once, you don't need use variables. But if you want to use the variable multiple times, you had better use variables. Using variable can simplify your template to avoid duplication of content.

For example, if you don't use supportLogStorageAccountName more than once, you can just do:

"name": "[toLower(concat('sf', uniqueString(resourceGroup().id),'2'))]"

However if you use provide variable supportLogStorageAccountName several\many times, you can use variable to avoid duplication.



Answered By - Shui shengbao
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing