Q6: Can you iterate over an array in an ARM template? If yes, how?
Q7: What are nested Templates in ARM templates?
Q8: How do you define outputs in an ARM template?
Q9: How do you secure sensitive information in ARM templates?
Q10: What is the mode property in ARM template deployments?
==========================================================================
Q6: Can you iterate over an array in an ARM template? If yes, how?
Answer:
Yes, you can use the copy element to iterate over an array and create multiple instances of a resource.
Yes, you can absolutely iterate over an array in an ARM template — and this is one of the most powerful ways to create multiple similar resources dynamically. The magic keyword here is
copy, which allows you to loop over arrays and create resources or properties multiple times without manually duplicating blocks.There are two ways:
1. Iterating at the Resource Level.
2. Iterating at the Property Level
==========================================================================
Q7: What are nested Templates in ARM templates?
Answer:
Nested templates come into picture when you breakdown the complex deployment is smaller, more manageable pieces. They get embedded within the main template during the run time.
The idea is if we have a big Main Template, we break it down to multiple templates like mainTemplate.yml, Nested1.yml, Nested2.yml. These Nested1.yml and Nested2.yml will be residing in Azure repo at same path where my mainTemplate.yml is placed.
We can use "type": "Microsoft.Resources/deployments" under resources and provide name of nestedtemplate in our mailTemplate.yml and in this way all will go as a single temple mainTemplate.yml while running.
Dependencies are managed using the dependsOn element, which ensures that resources are deployed in the correct order.
==========================================================================
Q8: How do you define outputs in an ARM template?
Answer:
Outputs are defined in the outputs section of the template and can be used to return values after the deployment is complete.
We can use outputs in following cases:
1. Retrieving connection string: When deploying a database such as Azure SQL, we can retrieve connection string to configure your application.
2. Getting Public IP address: When deploying a load balancer or a virtual machine, we can get the public ip address.
3. Returning Endpoints: While deploying Azure Storage or Azure app service we can get the endpoints value.
We can see the output section from the deployment ARM page itself. Eg:
==========================================================================
Q9: How do you secure sensitive information in ARM templates?
Answer:
Sensitive information can be secured using Azure Key Vault to store secrets and reference them in the template.
>> We can enable ARM template access property in Azure Key vaults to true.
>> In ARM template use the key to get the value.
==========================================================================
Q10: What is the mode property in ARM template deployments?
Answer:
The mode property can be set to Incremental or Complete.
Incremental adds resources without affecting existing ones,
while Complete deletes resources not defined in the template.
The default mode is Incremental.
==========================================================================

No comments:
Post a Comment