Otitoju Mercy
Posted on August 19, 2024
An ARM template is a file, written in JSON format, that tells Azure exactly how you want your cloud resources to be set up. Think of it as a blueprint that describes what resources you need, like virtual machines or databases, and how they should be configured. Instead of manually clicking around in the Azure portal to create these resources, you use the ARM template to automate the process. This makes it easier to deploy, manage, and repeat setups, ensuring everything is done consistently every time.
Key Concept of ARM Template.
The key concepts of an ARM (Azure Resource Manager) template include:
Declarative Syntax: ARM templates describe the desired state of your infrastructure in a declarative manner. You specify what resources you want, and Azure Resource Manager takes care of creating and configuring them.
Resources: The core of an ARM template is the list of resources you want to deploy, such as virtual machines, storage accounts, and databases. Each resource is defined with its type, properties, and dependencies.
Parameters: ARM templates can include parameters that allow you to pass in values at deployment time, making the template flexible and reusable. For example, you can define a parameter for the VM name or size.
Variables: Variables are used within the template to store values that can be reused throughout the template, making it easier to manage and update.
Outputs: Outputs allow you to return values from the template after the deployment is complete, such as the IP address of a deployed VM.
Methods of Deploying ARM Templates.
Azure Portal: Deploy ARM templates directly through the Azure web interface. Useful for users who prefer a graphical interface or need to make quick deployments.
Azure CLI (Command-Line Interface):Deploy ARM templates using commands in a terminal or script. Ideal for automation, scripting, and integration with CI/CD pipelines.
Azure PowerShell: Deploy ARM templates using PowerShell commands. Preferred by users familiar with PowerShell, useful for automation and scripts.
Azure DevOps: Integrate ARM template deployments into your CI/CD pipelines using Azure DevOps. Best for continuous integration/continuous deployment (CI/CD) environments and managing deployments across multiple stages.
Steps to Deploy a Virtual Machine Using an ARM Template.
In a web browser, go to the
Azure portal
and sign in.From the Azure portal search bar, search for deploy a custom template and then select it from the available options.
- Select Build your own template in the editor.
- You see a blank template.
- Replace the blank template with the following template. It following template. It deploys a virtual network with a subnet.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"type": "string",
"defaultValue": "VNet1",
"metadata": {
"description": "VNet name"
}
},
"vnetAddressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "Address prefix"
}
},
"subnetPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/24",
"metadata": {
"description": "Subnet Prefix"
}
},
"subnetName": {
"type": "string",
"defaultValue": "Subnet1",
"metadata": {
"description": "Subnet Name"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2021-08-01",
"name": "[parameters('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('vnetAddressPrefix')]"
]
},
"subnets": [
{
"name": "[parameters('subnetName')]",
"properties": {
"addressPrefix": "[parameters('subnetPrefix')]"
}
}
]
}
}
]
}
Select Save.
In the next blade, you provide custom values to use for the deployment.
For Resource group, select Create new and provide myResourceGroup for the name. You can use the default values for the other fields. When you've finished providing values, select Review + create
- The portal validates your template and the values you provided. After validation succeeds, select Create to start the deployment.
- When the deployment completes, you see the status of the deployment. This time select the name of the resource group.
Congratulations on Successful Deploying a Virtual Machine using ARM Templates .
When the Azure resources are no longer needed, clean up the resources you deployed by deleting the resource group.
Posted on August 19, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.