Courses Job Ready Program Fresher Trainings AI For Class 7 to 12 Corporate Training Placements Tutorials
Free Learning Resources

IT Tutorials & Interview Prep

Free guides, interview Q&As, and job responsibility breakdowns — curated by industry veterans to help you crack MNC interviews

236+
Tutorial Articles
16
Topic Categories
100%
Free to Read
← Back to  Azure Administrator (AZ-104 )

Chapter 12 : Azure ARM Templates & Automation

 Azure Administrator (AZ-104 ) Last Updated: Aug 27, 2026

1.1 Introduction to Infrastructure as Code

Traditionally, Azure resources such as Virtual Machines, Storage Accounts, and Networks were created manually through the Azure Portal, one click at a time. As environments grow larger, this manual approach becomes slow, inconsistent, and prone to human error. Infrastructure as Code solves this problem by allowing an entire environment to be described in a code file and deployed automatically, the same way every time.

This section introduces the concept of Infrastructure as Code (IaC), explains why it is used, and highlights the benefits it brings to Azure resource management, especially for organizations that need to deploy the same infrastructure repeatedly and reliably.

What is Infrastructure as Code (IaC)?

Definition

Infrastructure as Code (IaC) is the practice of managing and provisioning computing infrastructure, such as Virtual Machines, Networks, and Storage, through machine-readable code files instead of manual configuration. In Azure, this code is most commonly written as a JSON-based ARM Template, though other formats such as Bicep are also used.

(Infrastructure as Code (IaC) एक ऐसी practice है जिसमें Azure resources जैसे Virtual Machines, Networks और Storage को manually create करने के बजाय, एक code file के माध्यम से define और deploy किया जाता है। यह code बार-बार उपयोग किया जा सकता है, जिससे हर बार एक जैसा environment तैयार होता है।)

Explanation

Instead of opening the Azure Portal and manually clicking through each screen to create a resource, an administrator writes a template file that describes exactly what needs to be created, including its name, size, region, and configuration. This file is then submitted to Azure, which reads the code and creates the resources automatically. Because the same file can be reused, the same infrastructure can be deployed again in a different environment, such as a test or production subscription, with guaranteed consistency.

(Administrator Azure Portal में manually click करने के बजाय एक template file लिखता है जिसमें resource का नाम, size, region और configuration पहले से define होता है। इस file को Azure में submit करने पर resources automatically create हो जाते हैं, और वही file दोबारा उपयोग करके test या production environment में भी consistent infrastructure बनाया जा सकता है।)

Example

ABC Technologies needs to create the same set of resources — one Virtual Network, one Storage Account, and two Virtual Machines — in both its Development and Production subscriptions. Instead of creating each resource manually twice, the team writes a single ARM Template once and deploys it to both subscriptions, ensuring both environments are configured identically.

Why Infrastructure as Code?

Infrastructure as Code is used mainly to remove the inconsistency and manual effort involved in creating cloud resources by hand. When resources are created manually, small differences such as a mistyped setting or a missed configuration option can easily happen, especially when the same environment must be built more than once.

(Infrastructure as Code का उपयोग मुख्य रूप से resources को manually बनाने में होने वाली गलतियों और असंगति (inconsistency) को कम करने के लिए किया जाता है। Manual तरीके से resources बनाते समय छोटी-छोटी गलतियाँ, जैसे गलत setting या छूटी हुई configuration, आसानी से हो सकती हैं।)

  • Removes repetitive manual steps in the Azure Portal
  • Ensures every deployment follows the exact same configuration
  • Makes it easy to recreate an environment in case of failure
  • Allows infrastructure to be reviewed and version-controlled like application code
  • Speeds up deployment of large or complex environments

Example

An organization that previously took two full days to manually configure a new project environment can reduce this to a few minutes by running a single, pre-written ARM Template, because the deployment process itself has already been defined in code.

Benefits of Infrastructure as Code

Infrastructure as Code offers several practical advantages for teams that manage Azure environments regularly.

1. Consistency

Because the same code file is used for every deployment, the resulting environment is configured identically each time, removing the risk of manual configuration drift between environments.

2. Repeatability

A template can be deployed as many times as needed, in the same subscription or a different one, without having to redo the manual steps required to build the environment from scratch.

3. Speed

Deploying infrastructure through code is significantly faster than clicking through the Azure Portal manually, especially when many resources need to be created together.

4. Version Control

Because infrastructure is defined as a code file, it can be stored in a source control system such as Git, allowing teams to track changes, review history, and roll back to an earlier version if required.

5. Reduced Human Error

Since the configuration is written once and reused, the chances of a manual mistake, such as selecting a wrong region or forgetting a setting, are greatly reduced.

(IaC के उपयोग से हर deployment consistent, तेज़ और कम गलतियों वाला होता है। साथ ही code को version control (जैसे Git) में save करके उसकी history भी track की जा सकती है।)

1.2 Azure Resource Manager (ARM)

Every action performed in Azure, whether through the Azure Portal, Azure CLI, PowerShell, or an ARM Template, is ultimately handled by a single service called Azure Resource Manager. This section explains what ARM is, why it is used, how its architecture works, and the central role it plays in managing every Azure resource.

What is Azure Resource Manager?

Definition

Azure Resource Manager (ARM) is the deployment and management service in Azure that receives requests to create, update, or delete resources, and processes them consistently regardless of which tool sent the request. It acts as the single control layer that all Azure management tools communicate with.

(Azure Resource Manager (ARM) Azure की वह management service है जो resources को create, update या delete करने के requests को receive करती है और उन्हें process करती है। चाहे request Azure Portal से आए, CLI से आए या ARM Template से, हर request अंत में ARM के through ही process होता है।)

Explanation

When an administrator creates a Virtual Machine using the Azure Portal, the Portal internally sends that request to Azure Resource Manager. The same happens when the request is sent using PowerShell, Azure CLI, or an ARM Template — in every case, ARM is the underlying service that authenticates the request, checks permissions, and finally instructs the correct Azure service to create the resource. This ensures that no matter which tool is used, the same rules and processes apply consistently.

(जब कोई administrator Azure Portal से VM बनाता है, तो Portal internally वह request Azure Resource Manager को भेजता है। चाहे request PowerShell, CLI या ARM Template से आए, हर बार ARM ही उस request को authenticate करता है, permissions check करता है, और सही Azure service को resource बनाने का निर्देश देता है।)

Example

ABC Technologies' administrators use different tools depending on the task — some prefer the Azure Portal for quick changes, while automation scripts use Azure CLI. Even though the tools are different, both paths go through Azure Resource Manager, so the resulting resources are managed under the same consistent rules and permissions.

Why Azure Resource Manager is Used

Azure Resource Manager is used because it provides a single, consistent management layer for the entire Azure environment, no matter which interface an administrator chooses to work with.

(Azure Resource Manager का उपयोग इसलिए किया जाता है क्योंकि यह पूरे Azure environment के लिए एक consistent management layer प्रदान करता है, चाहे administrator किसी भी tool का उपयोग क्यों न करे।)

  • Provides a single point of control for all Azure resources
  • Applies Role-Based Access Control (RBAC) consistently across all tools
  • Supports grouping related resources together using Resource Groups
  • Enables tagging of resources for cost tracking and organization
  • Allows resources to be deployed together using ARM Templates

ARM Architecture

Definition

ARM Architecture refers to the layered structure through which a management request travels — starting from a client tool, passing through Azure Resource Manager, and finally reaching the specific Resource Provider responsible for creating the requested Azure resource.

(ARM Architecture उस layered structure को दर्शाता है जिसके through कोई भी management request client tool से शुरू होकर Azure Resource Manager से गुज़रती है और अंत में उस Resource Provider तक पहुंचती है जो specific resource बनाने के लिए जिम्मेदार होता है।)

 

Explanation

A request first originates from a client tool such as the Azure Portal, Azure CLI, PowerShell, or a direct REST API call. This request is sent to Azure Resource Manager, which authenticates the user and checks whether they have the required permissions using Role-Based Access Control. Once validated, ARM forwards the request to the correct Resource Provider — for example, the Compute provider for a Virtual Machine or the Storage provider for a Storage Account — which then creates the actual Azure resource.

(Request सबसे पहले किसी client tool, जैसे Azure Portal, CLI, PowerShell या REST API से शुरू होता है। यह request Azure Resource Manager तक पहुंचता है, जो user को authenticate करता है और RBAC के through permissions check करता है। Validation के बाद ARM उस request को सही Resource Provider तक भेजता है, जैसे VM के लिए Compute provider या Storage Account के लिए Storage provider, जो वास्तविक resource create करता है।)

Role of ARM in Azure Resource Management

Azure Resource Manager plays a central role in how every Azure resource is created, organized, secured, and managed throughout its lifecycle.

(Azure Resource Manager Azure resources के पूरे lifecycle में — उन्हें create करने से लेकर organize और secure करने तक — एक केंद्रीय (central) भूमिका निभाता है।)

  • Organizes resources into Resource Groups for easier management
  • Enforces consistent security and access policies across all resources
  • Enables deployment of multiple related resources together using templates
  • Tracks the deployment history of every resource group
  • Allows resources to be locked to prevent accidental deletion or modification

Example

When ABC Technologies deploys an ARM Template containing a Virtual Network, a Storage Account, and a Virtual Machine, Azure Resource Manager coordinates the creation of all three resources together, records the deployment as a single operation, and groups all three resources inside the same resource group for easy management.

1.3 Azure ARM Templates

An ARM Template is the actual file that puts Infrastructure as Code into practice in Azure. This section explains what an ARM Template is, why it is used, the benefits it provides, and the overall workflow followed when working with one.

What is an Azure ARM Template?

Definition

An Azure ARM Template is a JSON file that defines the infrastructure and configuration for an Azure deployment in a declarative way — meaning the template describes what resources should exist, rather than the exact steps needed to create them one by one.

(Azure ARM Template एक JSON file होती है जिसमें Azure deployment के लिए infrastructure और configuration को declarative तरीके से define किया जाता है, यानी template में यह बताया जाता है कि कौन-कौन से resources होने चाहिए, न कि उन्हें step-by-step कैसे बनाया जाए।)

Explanation

Because ARM Templates are declarative, the administrator only needs to describe the desired end state, such as "one Storage Account with this name and this configuration," and Azure Resource Manager figures out the correct steps to reach that state. This is different from writing a script that gives Azure step-by-step instructions, and it makes templates easier to read, review, and maintain.

(ARM Templates declarative होने के कारण administrator को केवल यह बताना होता है कि अंत में क्या चाहिए, जैसे 'इस नाम और configuration का एक Storage Account चाहिए', और Azure Resource Manager खुद यह तय करता है कि उसे कैसे बनाना है। यह किसी script के step-by-step instructions देने से अलग है और template को पढ़ने व समझने में आसान बनाता है।)

Example

ABC Technologies writes an ARM Template describing a Storage Account with a specific name, region, and replication type. When this template is deployed, Azure Resource Manager automatically determines how to create that exact Storage Account, without the administrator having to specify each individual API call.

Why Do We Use ARM Templates?

ARM Templates are used mainly to deploy Azure resources in a repeatable, predictable, and automated way instead of creating them manually through the Azure Portal.

(ARM Templates का उपयोग मुख्य रूप से Azure resources को repeatable, predictable और automated तरीके से deploy करने के लिए किया जाता है, बजाय इसके कि उन्हें manually Azure Portal से बनाया जाए।)

  • Deploy multiple related resources together in a single operation
  • Reuse the same template across Development, Test, and Production environments
  • Maintain infrastructure definitions alongside application code in source control
  • Reduce the time required to set up a complete environment
  • Ensure that every deployment follows the same standard configuration

Benefits of ARM Templates

1. Consistency Across Environments

The same template can be deployed to Development, Test, and Production, ensuring that all three environments have an identical baseline configuration, which reduces environment-specific issues.

2. Faster Deployments

Multiple resources that would otherwise take significant time to configure manually can be deployed together in a single template execution, saving considerable time for larger environments.

3. Reusability

A well-written template can be reused for future projects with only minor changes to parameter values, avoiding the need to build the same configuration again from scratch.

4. Easier Auditing and Review

Because the template is a text file, it can be reviewed by team members before deployment and stored in version control, making it easy to track exactly what changed and when.

5. Dependency Management

ARM automatically understands and manages the order in which dependent resources should be created, such as creating a Virtual Network before the Virtual Machine that uses it.

(ARM Templates का उपयोग करने से deployments तेज़, consistent और आसानी से reuse होने योग्य बन जाती हैं, साथ ही resources के बीच dependency को भी ARM खुद manage करता है।)

ARM Template Workflow

Working with an ARM Template generally follows a defined sequence of steps, from writing the template to confirming that the deployment was successful.

  • Create the ARM Template describing the required resources
  • Define the parameters and variables the template will use
  • Define the resources section with the actual Azure resources
  • Validate the template to check for errors before deployment
  • Deploy the template to a resource group in Azure
  • Verify that the deployment completed successfully

(ARM Template के साथ काम करते समय पहले template लिखा जाता है, फिर parameters और variables define किए जाते हैं, resources define किए जाते हैं, template को validate किया जाता है, deploy किया जाता है, और अंत में deployment को verify किया जाता है।)

1.4 ARM Template Structure

An ARM Template follows a specific JSON structure that Azure Resource Manager expects. This section explains what JSON structure means, walks through the overall layout of an ARM Template, and describes each of its main components.

What is JSON Structure?

Definition

JSON (JavaScript Object Notation) is a lightweight, text-based format used to represent structured data using key-value pairs, arrays, and nested objects. ARM Templates are written in this JSON format because it is easy for both humans to read and machines to process.

(JSON (JavaScript Object Notation) एक lightweight, text-based format है जिसमें data को key-value pairs, arrays और nested objects के रूप में represent किया जाता है। ARM Templates इसी JSON format में लिखे जाते हैं क्योंकि इसे इंसान और मशीन दोनों आसानी से समझ सकते हैं।)

Explanation

In JSON, data is organized using curly braces {} for objects and square brackets [] for lists of items called arrays. Each piece of information is stored as a "key": "value" pair, for example "location": "East US". This simple structure allows an ARM Template to describe complex Azure environments, including many resources and their settings, in a single readable file.

(JSON में data को curly braces {} के through objects के रूप में और square brackets [] के through arrays यानी items की list के रूप में organize किया जाता है। हर जानकारी 'key': 'value' pair के रूप में store होती है, जैसे 'location': 'East US'। यही simple structure ARM Template को एक readable file में पूरे complex environment को describe करने की सुविधा देता है।)

ARM Template Structure

Every ARM Template follows the same top-level JSON structure, which consists of a fixed set of sections. Some of these sections are required, while others, such as parameters and outputs, are optional depending on the needs of the deployment.

{
"$schema": "https://schema.management.azure.com/...",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": { },
"resources": [ ],
"outputs": { }
}

(हर ARM Template इसी fixed structure को follow करता है — इसमें schema, contentVersion, parameters, variables, resources और outputs जैसी sections होती हैं। इनमें से resources हमेशा जरूरी होता है, जबकि parameters और outputs जरूरत के अनुसार optional भी हो सकते हैं।)

Components of an ARM Template

Schema

The $schema element specifies the location of the JSON schema file that describes the structure of the template. It tells Azure and code editors which version of the ARM Template language is being used, enabling proper validation and IntelliSense support.

($schema element यह बताता है कि template किस JSON schema file को follow कर रहा है। इससे Azure और code editors को यह पता चलता है कि ARM Template language का कौन-सा version उपयोग किया जा रहा है।)

ContentVersion

The contentVersion element holds a version number for the template, such as 1.0.0.0. This value is defined and managed by the author of the template and is useful for tracking changes when the template is updated over time.

(contentVersion element में template का एक version number होता है, जैसे 1.0.0.0। इसे template लिखने वाला खुद manage करता है, और यह template में समय के साथ हुए बदलावों को track करने में मदद करता है।)

Parameters

The parameters section defines the values that must be supplied when the template is deployed, such as a resource name, location, or Virtual Machine size. Parameters make the same template reusable for different deployments with different values.

(parameters section में वे values define होती हैं जो template deploy करते समय दी जाती हैं, जैसे resource का नाम, location या VM size। इससे एक ही template को अलग-अलग values के साथ बार-बार उपयोग किया जा सकता है।)

Variables

The variables section defines values that are used and reused within the template itself, rather than being supplied by the user. Variables help simplify complex expressions and avoid repeating the same value multiple times throughout the template.

(variables section में वे values होती हैं जो template के अंदर ही उपयोग और reuse की जाती हैं, न कि user द्वारा दी जाती हैं। यह complex expressions को simplify करने और एक ही value को बार-बार लिखने से बचाने में मदद करता है।)

Resources

The resources section is the most important part of the template — it contains the actual list of Azure resources, such as Virtual Networks, Storage Accounts, or Virtual Machines, that should be created or updated when the template is deployed.

(resources section template का सबसे महत्वपूर्ण हिस्सा होता है — इसमें उन actual Azure resources की list होती है, जैसे Virtual Network, Storage Account या VM, जिन्हें template deploy करते समय create या update किया जाना है।)

Outputs

The outputs section defines values that should be returned after the deployment completes, such as the public IP address of a newly created VM. These output values can then be used by scripts or other templates that run afterward.

(outputs section में वे values define होती हैं जो deployment पूरी होने के बाद return की जाती हैं, जैसे नई बनी VM का public IP address। इन output values का उपयोग बाद में चलने वाले scripts या अन्य templates में किया जा सकता है।)

1.5 ARM Template Parameters

Parameters make an ARM Template flexible so that the same template can be deployed with different values each time. This section explains what parameters are, why they are used, the different parameter types available, and how they work during deployment.

What are ARM Template Parameters?

Definition

ARM Template Parameters are values that are supplied by the person or process deploying the template, rather than being fixed inside the template itself. They allow details such as resource names, sizes, or locations to change from one deployment to the next without editing the template file.

(ARM Template Parameters वे values होती हैं जो template deploy करने वाले व्यक्ति या process द्वारा दी जाती हैं, न कि template के अंदर पहले से fixed होती हैं। इनकी मदद से resource का नाम, size या location जैसी details हर deployment में बिना template file बदले अलग-अलग दी जा सकती हैं।)

Explanation

When a template is deployed, Azure prompts for any required parameter values, either through the Azure Portal's deployment form, a parameters file, or command-line input. These supplied values are then used throughout the template wherever that parameter is referenced, allowing the same template to produce different results depending on the input provided.

(Template deploy करते समय Azure जरूरी parameters की values मांगता है, चाहे वह Azure Portal के deployment form से हो, parameters file से हो या command-line से। दी गई values template में जहां भी उस parameter को reference किया गया है, वहां उपयोग होती हैं, जिससे एक ही template अलग-अलग input के आधार पर अलग परिणाम दे सकता है।)

Example

A template that creates a Storage Account defines a parameter called storageAccountName. When ABC Technologies deploys this template for its Development environment, it supplies the value "devstorage01"; when deploying to Production, it supplies "prodstorage01" instead, using the exact same template file both times.

Why Parameters are Used

Parameters are used to make ARM Templates reusable and flexible, so that a single template can serve multiple deployments instead of requiring a separate template for every environment.

(Parameters का उपयोग ARM Templates को reusable और flexible बनाने के लिए किया जाता है, ताकि एक ही template कई deployments के लिए काम आ सके, न कि हर environment के लिए अलग template बनाना पड़े।)

  • Allow the same template to be used across multiple environments
  • Avoid hard-coding values such as names, sizes, or regions inside the template
  • Enable different teams to deploy the same template with their own values
  • Support secure input of sensitive values such as passwords

Parameter Types

ARM Templates support several data types for parameters, allowing different kinds of values to be supplied and validated correctly during deployment.



 

Parameter TypeDescription
stringA text value, such as a resource name or region
intA whole number value, such as the number of VM instances
boolA true or false value, such as enabling a feature
objectA JSON object containing multiple related settings
arrayA list of values, such as multiple subnet names
secureStringA text value that is hidden, used for passwords or secrets



 

(ARM Templates में parameters के लिए कई types उपलब्ध होते हैं, जैसे string (text), int (number), bool (true/false), object, array और secureString, जो passwords जैसी sensitive values को छुपाकर रखता है।)

How Parameters Work in ARM Templates

A parameter is first declared in the parameters section of the template with its type and, optionally, a default value or allowed set of values. It is then referenced elsewhere in the template using the parameters() function, wherever that value is needed.

(Parameter को पहले template के parameters section में उसके type के साथ declare किया जाता है, और चाहे तो एक default value या allowed values की list भी दी जा सकती है। इसके बाद इसे template में जहां भी जरूरत हो, parameters() function के through reference किया जाता है।)

"parameters": {
"storageAccountName": {
"type": "string",
"defaultValue": "mystorageacct"
}
}

1.6 ARM Template Variables

While parameters accept values from the person deploying the template, variables are values calculated or defined within the template itself. This section explains what variables are, why they are used, and how they work.

What are ARM Template Variables?

Definition

ARM Template Variables are values that are defined once inside the template and then reused multiple times throughout the same template, rather than being supplied externally by the user. They are often built by combining parameter values or fixed text using template expressions.

(ARM Template Variables वे values होती हैं जो template के अंदर ही एक बार define की जाती हैं और फिर पूरे template में कई जगह reuse की जाती हैं, न कि user द्वारा बाहर से दी जाती हैं। इन्हें अक्सर parameters या fixed text को combine करके template expressions से बनाया जाता है।)

Explanation

Variables are especially useful when the same computed value, such as a resource name built from a prefix and the environment name, is needed in several places within the resources section. Defining it once as a variable avoids repeating the same expression and makes the template easier to update, since the value only needs to change in one place.

(Variables खासतौर पर तब useful होते हैं जब कोई एक ही calculated value, जैसे prefix और environment नाम को जोड़कर बना resource name, template में कई जगह चाहिए हो। इसे एक बार variable के रूप में define करने से बार-बार वही expression लिखने की जरूरत नहीं पड़ती।)

Example

ABC Technologies defines a variable called vnetName that combines a fixed prefix with the environment parameter, producing a value such as "abc-dev-vnet". This variable is then reused wherever the Virtual Network name is needed inside the template's resources section.

Why Variables are Used

Variables are used to simplify ARM Templates and avoid repeating the same expressions or values multiple times within the file.

(Variables का उपयोग ARM Templates को simple बनाने और एक ही expression या value को बार-बार दोहराने से बचने के लिए किया जाता है।)

  • Reduce repetition of complex expressions within the template
  • Make templates easier to read and maintain
  • Allow a single change to update a value used in many places
  • Combine parameters and fixed values into a single reusable value

How Variables Work in ARM Templates

A variable is declared in the variables section of the template, often using an expression that references one or more parameters. It is then used elsewhere in the template with the variables() function, wherever that computed value is required.

(Variable को template के variables section में declare किया जाता है, अक्सर किसी parameter को reference करते हुए एक expression के रूप में। इसके बाद इसे template में जहां भी उस value की जरूरत हो, वहां variables() function के through उपयोग किया जाता है।)

"variables": {
"vnetName": "[concat('abc-', parameters('environment'), '-vnet')]"
}

1.7 ARM Template Resources

The resources section is where the actual Azure infrastructure is defined. This section explains what resources are in the context of an ARM Template, how a resource is defined, what resource properties look like, and how resources are deployed.

What are Resources?

Definition

In an ARM Template, Resources refer to the actual Azure services being created or configured, such as a Virtual Network, Storage Account, Virtual Machine, or Network Security Group. Every resource that should exist after deployment must be listed inside the resources array of the template.

(ARM Template में Resources उन actual Azure services को कहा जाता है जिन्हें create या configure किया जाना है, जैसे Virtual Network, Storage Account, Virtual Machine या Network Security Group। Deployment के बाद जो भी resource होना चाहिए, उसे template के resources array में list किया जाना जरूरी है।)

Explanation

Each entry in the resources array describes one Azure resource in detail, including its type, name, location, and specific configuration settings. Azure Resource Manager reads through this array and creates each listed resource, automatically handling any dependencies between them, such as creating a Virtual Network before a subnet that belongs to it.

(resources array की हर entry एक Azure resource को विस्तार से describe करती है, जिसमें उसका type, नाम, location और configuration settings शामिल होती हैं। Azure Resource Manager इस array को पढ़कर हर resource को create करता है और उनके बीच dependency को खुद ही सही क्रम में handle करता है।)

Resource Definition

A resource definition inside the template requires certain standard properties that identify what the resource is and how it should be configured.

{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2023-01-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": { "name": "Standard_LRS" },
"kind": "StorageV2"
}

(Template के अंदर किसी भी resource को define करने के लिए type, apiVersion, name और location जैसी standard properties देना जरूरी होता है, जो यह बताती हैं कि resource क्या है और उसे कैसे configure किया जाना है।)

Resource Properties

Every resource definition includes a common set of properties that Azure Resource Manager uses to identify and create the resource correctly.

PropertyPurpose
typeIdentifies the resource provider and resource type, e.g. Microsoft.Storage/storageAccounts
apiVersionSpecifies which version of the resource provider API to use
nameThe name given to the resource once created
locationThe Azure region where the resource will be deployed
propertiesResource-specific configuration settings and options

(हर res ource definition में कुछ common properties होती हैं, जैसे type (resource का प्रकार), apiVersion, name और location, जो Azure Resource Manager को resource को सही तरीके से पहचानने और बनाने में मदद करती हैं।)

Deploying Azure Resources Using ARM Templates

Once the resources section is complete, the template can be deployed to a resource group using the Azure Portal, Azure CLI, or PowerShell. Azure Resource Manager reads the entire resources array and creates every listed resource, respecting any dependencies defined between them, such as one resource requiring another to exist first.

(resources section पूरा होने के बाद template को Azure Portal, CLI या PowerShell का उपयोग करके किसी resource group में deploy किया जा सकता है। Azure Resource Manager पूरे resources array को पढ़ता है और उनके बीच defined dependencies को ध्यान में रखते हुए हर resource को सही क्रम में create करता है।)

Example

A template that includes both a Virtual Network and a Virtual Machine that uses that network will automatically deploy the Virtual Network first, because the Virtual Machine resource depends on it, ensuring the deployment does not fail due to a missing dependency.

1.8 ARM Template Outputs

After a template finishes deploying resources, it is often useful to retrieve certain values generated during that deployment. This section explains what outputs are, why they are used, what kind of values can be returned, and how they are used after deployment.

What are Outputs?

Definition

Outputs in an ARM Template are values that are returned to the user or calling process once the deployment has completed successfully. They are typically used to expose information about a newly created resource, such as its resource ID, IP address, or connection details.

(ARM Template में Outputs वे values होती हैं जो deployment successfully complete होने के बाद user या calling process को return की जाती हैं। इनका उपयोग आमतौर पर नए बने resource की जानकारी, जैसे उसका resource ID, IP address या connection details, बाहर दिखाने के लिए किया जाता है।)

Explanation

An output is defined by referencing a property of a resource that was created in the same template, such as its public IP address. Once the deployment finishes, Azure returns this value, which can then be viewed in the Azure Portal, captured by a script, or passed into another template as an input.

(Output को define करने के लिए template में बनाए गए किसी resource की property को reference किया जाता है, जैसे उसका public IP address। Deployment पूरी होने पर Azure यह value return करता है, जिसे Azure Portal में देखा जा सकता है, किसी script द्वारा capture किया जा सकता है या किसी दूसरे template में input के रूप में उपयोग किया जा सकता है।)

Why Outputs are Used

Outputs are used to make important post-deployment information easily accessible, without requiring the administrator to manually search for it in the Azure Portal after the deployment finishes.

(Outputs का उपयोग deployment के बाद जरूरी जानकारी को आसानी से उपलब्ध कराने के लिए किया जाता है, ताकि administrator को उसे manually Azure Portal में जाकर ढूंढना न पड़े।)

  • Return values such as IP addresses or connection strings after deployment
  • Provide input values for scripts that run after the deployment
  • Pass values from one template to another in linked deployments
  • Confirm key configuration details without opening the Azure Portal

Output Values

An output value is declared with a name and type, along with an expression that retrieves the required information from a resource defined in the same template.

"outputs": {
"storageEndpoint": {
"type": "string",
"value": "[reference(parameters('storageAccountName')).primaryEndpoints.blob]"
}
}

(Output value को एक नाम और type के साथ declare किया जाता है, साथ ही एक expression दिया जाता है जो template में बने किसी resource से जरूरी जानकारी निकालता है।)

Using Outputs After Deployment

After a deployment completes, output values can be viewed in the Azure Portal under the deployment's overview page, or retrieved programmatically using Azure CLI or PowerShell commands. This makes it easy to feed the result of one deployment into the next step of an automated process.

(Deployment पूरी होने के बाद output values को Azure Portal में deployment के overview page पर देखा जा सकता है, या Azure CLI और PowerShell commands के through भी प्राप्त किया जा सकता है। इससे एक deployment के result को अगले automated step में आसानी से उपयोग किया जा सकता है।)

Example

After deploying a template that creates a Virtual Machine, ABC Technologies uses the output section to retrieve the VM's public IP address automatically, rather than manually searching for it in the Azure Portal after deployment.

1.9 ARM Template Workflow

This section walks through the complete end-to-end workflow followed when working with an ARM Template, from initial creation through to final verification after deployment.

 

Create ARM Template

The workflow begins by creating the ARM Template file itself, either by writing it from scratch, starting from an existing sample template, or exporting the JSON definition of an existing resource group directly from the Azure Portal.

(Workflow की शुरुआत ARM Template file बनाने से होती है, चाहे उसे शुरू से लिखा जाए, किसी sample template से शुरुआत की जाए, या Azure Portal से किसी existing resource group की JSON definition export की जाए।)

Define Parameters and Variables

Next, the parameters that should be supplied at deployment time are defined, along with any variables needed to simplify expressions used later in the resources section. This step determines how flexible and reusable the final template will be.

(इसके बाद वे parameters define किए जाते हैं जो deployment के समय दिए जाएंगे, साथ ही वे variables भी define किए जाते हैं जो बाद में resources section में expressions को simplify करने के लिए जरूरी हों।)

Define Resources

The resources section is then written, listing every Azure resource that should be created, along with its type, name, location, and configuration properties, including any dependencies between resources.

(इसके बाद resources section लिखा जाता है, जिसमें हर उस Azure resource को list किया जाता है जो create किया जाना है, साथ ही उसका type, नाम, location और configuration properties भी दी जाती हैं।)

Validate Template

Before deploying, the template is validated to check for syntax errors, missing required properties, or incorrect resource type references. Validation catches many issues early, without actually creating any resources in Azure.

(Deploy करने से पहले template को validate किया जाता है, ताकि syntax errors, missing properties या गलत resource type जैसी समस्याओं का पहले ही पता चल सके, बिना कोई actual resource बनाए।)

Deploy Resources

Once validation passes, the template is deployed to a target resource group using the Azure Portal, Azure CLI, or PowerShell. Azure Resource Manager then processes the template and creates all the defined resources.

(Validation successful होने के बाद template को Azure Portal, CLI या PowerShell का उपयोग करके किसी resource group में deploy किया जाता है, और Azure Resource Manager सभी defined resources को create करता है।)

Verify Deployment

Finally, the deployment is verified by checking the deployment status in the Azure Portal, confirming that every resource was created successfully, and reviewing any output values returned by the template.

(अंत में deployment को verify किया जाता है, यह check करके कि Azure Portal में deployment status successful दिख रहा है या नहीं, सभी resources सही से बने हैं या नहीं, और template द्वारा दिए गए output values की भी समीक्षा की जाती है।)

1.10 ARM Template Validation

Validating a template before deployment helps catch mistakes early, saving time and avoiding partially completed deployments. This section explains what template validation is, why it is required, how to validate a template before deployment, and common issues found during validation.

What is ARM Template Validation?

Definition

ARM Template Validation is the process of checking a template's syntax and structure against Azure's requirements before it is actually deployed, in order to detect errors without creating any real resources.

(ARM Template Validation एक ऐसी process है जिसमें actual deployment से पहले template की syntax और structure को Azure की requirements के अनुसार check किया जाता है, ताकि बिना कोई real resource बनाए errors का पता लगाया जा सके।)

 

Explanation

When a validation command is run, Azure Resource Manager checks the template for issues such as missing required properties, incorrect data types, or invalid resource type names, and reports any problems found. Because this check does not create actual resources, it is a safe and quick way to test a template before committing to a real deployment.

(Validation command चलाने पर Azure Resource Manager template में missing properties, गलत data types या invalid resource type names जैसी समस्याओं को check करता है और उन्हें report करता है। यह check कोई actual resource नहीं बनाता, इसलिए यह template को test करने का एक safe और तेज़ तरीका है।)

Why Template Validation is Required

Validation is required because deploying a large template with an error partway through can leave the environment in a partially created state, which can be time-consuming and confusing to clean up.

(Validation इसलिए जरूरी है क्योंकि किसी बड़े template में गलती होने पर deployment बीच में रुक सकती है, जिससे environment partially बना रह जाता है और उसे ठीक करना समय लेने वाला और confusing हो सकता है।)

  • Detects syntax and structural errors before deployment starts
  • Prevents partially completed deployments caused by template mistakes
  • Saves time by catching issues without waiting for a full deployment to fail
  • Improves confidence in the template before it is used in production

Validate Template Before Deployment

A template can be validated using the Azure Portal's custom deployment screen, or by running a validation command through Azure CLI or PowerShell before submitting the actual deployment request.

az deployment group validate \
--resource-group myResourceGroup \
--template-file azuredeploy.json \
--parameters azuredeploy.parameters.json

(Template को Azure Portal की custom deployment screen से validate किया जा सकता है, या actual deployment request भेजने से पहले Azure CLI या PowerShell के through validation command चलाई जा सकती है।)

Common Validation Issues

Certain mistakes appear frequently when working with ARM Templates, and being aware of them helps in writing templates correctly the first time.

  • Missing required properties for a resource type
  • Referencing a parameter or variable name that does not exist
  • Using an incorrect or outdated apiVersion for a resource
  • Incorrect JSON syntax, such as a missing comma or bracket
  • Circular or incorrect dependencies between resources

(ARM Templates में कुछ गलतियाँ अक्सर देखने को मिलती हैं, जैसे missing properties, गलत parameter या variable name, पुराना apiVersion, JSON syntax में गलती, या resources के बीच गलत dependency।)

1.11 ARM Template Best Practices

Following a consistent set of best practices makes ARM Templates easier to read, maintain, and reuse across a team or organization. This section covers key recommendations that should be followed when writing ARM Templates.

1. Use Parameters for Reusable Templates

Values that are likely to change between deployments, such as resource names, sizes, or regions, should be defined as parameters rather than hard-coded, so the same template can be reused across multiple environments without modification.

(जो values deployment के अनुसार बदल सकती हैं, जैसे resource का नाम, size या region, उन्हें hard-code करने के बजाय parameters के रूप में define करना चाहिए, ताकि template को बिना बदले कई environments में reuse किया जा सके।)

2. Use Variables Where Required

Complex expressions or values that are reused multiple times within the template should be defined as variables, keeping the resources section cleaner and easier to update later.

(जो complex expressions या values template में कई बार उपयोग होती हैं, उन्हें variables के रूप में define करना चाहिए, जिससे resources section साफ और बाद में update करने में आसान बना रहे।)

3. Keep Templates Organized

Templates should be structured logically, with related resources grouped together and consistent naming conventions used throughout, making the file easier for other team members to read and understand.

(Templates को logically organize करना चाहिए, related resources को एक साथ group करना चाहिए, और पूरे template में consistent naming conventions follow करनी चाहिए, ताकि दूसरे team members के लिए इसे समझना आसान हो।)

4. Validate Templates Before Deployment

Every template should be validated before it is deployed to any environment, especially production, to catch errors early and avoid partially completed deployments.

(हर template को deploy करने से पहले validate करना चाहिए, खासकर production environment में, ताकि गलतियाँ जल्दी पकड़ी जा सकें और partial deployment से बचा जा सके।)

5. Use Meaningful Resource Names

Resources should be given clear, descriptive names that indicate their purpose and environment, such as "prod-vnet-eastus", making it easier to identify resources later within the Azure Portal or resource group.

(Resources को ऐसे clear और descriptive नाम देने चाहिए जिनसे उनका उद्देश्य और environment पता चले, जैसे 'prod-vnet-eastus', ताकि बाद में Azure Portal में उन्हें पहचानना आसान हो।)

6. Reuse Templates for Consistent Deployments

Instead of writing a new template for every project, existing, well-tested templates should be reused and adapted where possible, ensuring consistent configuration and reducing the chance of introducing new errors.

(हर project के लिए नया template लिखने के बजाय, पहले से बने और अच्छी तरह tested templates को reuse और थोड़ा modify करके उपयोग करना चाहिए, जिससे configuration consistent बनी रहे और नई गलतियों की संभावना कम हो।)

1.12 Practical Labs

The following practical labs provide hands-on experience with ARM Templates. These exercises help you understand how to write, validate, and deploy an ARM Template to create real Azure resources.

Practical 1: Export and Explore an ARM Template

Objective

To export the ARM Template of an existing resource group from the Azure Portal and explore its structure.

Steps

  • Log in to the Azure Portal and open an existing Resource Group.
  • Select Export Template from the left-hand menu.
  • Review the generated JSON template.
  • Identify the parameters, variables, resources, and outputs sections.
  • Download the template file for reference.

Learning Outcome

After completing this lab, you should be able to locate and read the structure of a real ARM Template exported from an existing Azure environment.

Practical 2: Create and Deploy a Simple ARM Template

Objective

To write a simple ARM Template that deploys a Storage Account and deploy it using the Azure Portal.

Steps

  • Open the Azure Portal and search for Deploy a custom template.
  • Select Build your own template in the editor.
  • Write a template containing a parameters section for the storage account name and location.
  • Add a resources section defining a Storage Account resource.
  • Save the template and select the target Resource Group.
  • Provide the required parameter values and select Review + Create.
  • Deploy the template and wait for the deployment to complete.

Learning Outcome

After completing this lab, you should be able to write a basic ARM Template and successfully deploy it through the Azure Portal.

Practical 3: Validate a Template Before Deployment

Objective

To validate an ARM Template using Azure CLI before deploying it, and to identify and fix a validation error.

Steps

  • Open Azure Cloud Shell or a local terminal with Azure CLI installed.
  • Sign in to Azure using the az login command.
  • Run the az deployment group validate command against the template file.
  • Review the output for any reported errors.
  • Intentionally introduce a small error, such as an incorrect apiVersion, and validate again.
  • Correct the error and re-validate until the template passes.

Learning Outcome

After completing this lab, you should be able to validate an ARM Template using Azure CLI and identify common causes of validation errors.

Practical 4: Use Outputs to Retrieve Deployment Values

Objective

To add an outputs section to a template and retrieve a resource property after deployment.

Steps

  • Open a previously created ARM Template that deploys a Storage Account.
  • Add an outputs section that returns the storage account's primary blob endpoint.
  • Deploy the updated template to a Resource Group.
  • Open the deployment in the Azure Portal and view the Outputs tab.
  • Verify that the correct endpoint value is displayed.

Learning Outcome

After completing this lab, you should be able to define an outputs section in an ARM Template and retrieve deployment results after a successful deployment.

 

Related: Azure System Administration - Job Ready Internship Program.