Now let's look at how you can make your arm templates more flexible and reusable.
The first think will look at some restrictions that the arm time place here
you're limited to 256 parameters, 256 variables, 803 sources,
64 output values and 24,576 characters in a template expression.
However, you can overcome some of those limitations if you use Lincoln templates.
Also, if you need to have a lot of parameters and outputs, you can use objects and combine multiple parameters or outputs in a single object.
Here are some guidelines You should fall when you design arm templates.
Never hard cold secrets in the template.
One option is to use a secure string for Para matters when the secrets must be specified interactively.
Another is to use key vote and read the secrets from there.
Use the Ford values for para matters to simplify the input. One typical example. With location you can dynamically obtained the location from the resource group where the resource group are deported and only specified when the resource is vocation should be different.
Use very Abel's for values that you need to use more than once and are constructed using complex expressions.
One typical example was to use variables to enforce consistency. Naming
another is to construct the resource identifiers that you can use for dependencies.
Don't car called resource identifiers. If use the resource i d and the reference functions, you can make your templates independent of the subscription and the resource group. It is the point toe.
This makes it more flexible.
He's meta data to help other contributors to the template. Examples are the comments property of the Resource is or the meta data property of the Para matters.
Let's see how we can imply some of those guidelines to our template.
The first thing we'll do is at some default values for the parameters.
Let's start with the occasion. As you remember, we said that you can get the location from the resource group where the resources are the point. So if you type default value
inside square brackets, you can say resource group that location.
This way, you can obtain the resource group location and put it towards the perimeter for these template.
Next thing we can do is we cannot. Some other default values. Let's say the storage account type
and we will put for storage account type, standard
We will put
storage V two
and storage steer
we can, even at the Ford values that are not simple strings, Let's say our race, for example,
Here I'll just put the
D Ford fellow US array
for the address prefixes and the same thing I can do. Also, for the seven it's
the next thing will do in our template is to use some standard naming conventions. Isn't letting, for example, the user to type the storage account name and the virtual network name?
We would like to use some naming convention for that.
Let's say, for example, we would like to have naming convention that uses the up name, then it here's the environment, and at the end it has some so fix, which denotes the type of resource.
We'll remove the freeform parliamentary for virtual network name in storage account name
and well at new ones, and put some constraints on them. Let's say our first perimeter will be up
and we'll hear this type sprink also,
we'll put Max length for this, and we'll say the length of the up name should not be more than eight characters.
The next thing we will do is we want some meta data
which will show up either when the prompt is asking for the perimeter input or in the Port O as a help desk, we can say this is
the application name Abbreviation
Limited toe eight characters.
So this is a careful task that can a text that can be used by tools us where waas other people working on the template,
the next part of matter that will at his environment.
And we'll say again, this is types drink
and we'll say, Max Lang is four characters
in that meta data description
This is the environment
limited to four character,
and we'll put there.
They just brought in parent disease to give some idea what that means.
Now that we have our new partner mentors
east it using the storage account name as part of matter in the virtual network name Isparta matter will build the variables with those names storage account, name,
and this will be equal to
the lower case of the platter. Mater, My up
or up name.
Then we'll let at the lower case of the environment
uh, part of me too
And at the end, we'll just at the stink str for storage
this way. Our storage a canny our camp name will be standardized. It will have the up name, then the environment. Let's say death test or production and then str at the end
everything will be lower case. I will not have mixed case and will not rely on the user to type the proper case.
We can go see me were think with the virtual network name.
However virtual network names. They support not only alphanumeric characters but also dashes so we cannot dashes to the virtual network name.
I'll just copy the same thing
out Dash v. Net A specifics
and I also up another dash in between.
Now that we have our new partner matters and we build the standard names we need to go and in the resource section change the name for each resource toe. Not accept the para matter value but the very Able Bailey.
So we changed the name for the storage account and we change the name for the vitriol networks.
The next thing we will do is well at some output. In orderto do the output we need to reference the storage account.
Let's create a new valuable for the storage account idea.
This very able
can be built using the resource I D function
that is built into the arm templates.
In order to build our output,
we need to go at one additional property. Tow the output. Let's say that will be globe in 20
well, type you Stipe stink for the end point. Okay, this will be the U. L that we can use to access Diane Point.
And for the value
we will say
it is a reference
toe. Very ables
and the valuable will be storage account i D.
And we'll use the 2019
0601 AP. I tow dough that reference
and we'll get the primary and point
for the blow up
This way. Once the storage account is created, we can output the end point for its blob
You see how easy it is to generalize your templates and make them flexible.
Let's see how we can achieve even more flexibility with Linc templates