Azure Resource Manager (ARM) Documentation
Azure Resource Manager (ARM) is the deployment and management service for Azure. It provides a management layer that enables you to create, update, and delete resources in your Azure account. You can use familiar development tools for the same workflows to build and deploy your applications with a simple or complex orchestration.
Key Concepts
Understanding these core concepts is crucial for effective Azure resource management:
- Resources: Any manageable item that is available through Azure. For example, virtual machines, storage accounts, virtual networks, web apps, databases, etc.
- Resource Group: A logical container into which Azure resources like virtual machines, storage accounts, and virtual networks are deployed and managed. Resource groups can be used to organize resources by application, environment, or any other criteria.
- Template: A JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your Azure solution. ARM templates allow you to declaratively define the resources you want to deploy.
- Deployment: The process of deploying resources defined in an ARM template. Deployments can be performed via the Azure portal, Azure CLI, Azure PowerShell, or REST API.
- Provider: A service that offers Azure resources. Providers are typically resource types, like
Microsoft.Storage
orMicrosoft.Compute
. - Resource Type: The specific type of resource provided by a resource provider. For example,
Microsoft.Storage/storageAccounts
is a resource type.
ARM Templates
ARM templates are declarative JSON files that define your Azure infrastructure. They enable infrastructure as code (IaC) practices, ensuring consistency and repeatability.
Template Syntax
An ARM template has a JSON structure with specific sections:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { ... },
"variables": { ... },
"resources": [ ... ],
"outputs": { ... }
}
Parameters
Parameters allow you to pass values into your template during deployment, making them reusable and customizable.
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS",
"Premium_LRS"
],
"metadata": {
"description": "Specifies the replication type for the storage account."
}
}
}
Variables
Variables are used to store reusable values within your template.
"variables": {
"storageAccountName": "[concat(uniqueString(resourceGroup().id), 'storage')]",
"location": "[resourceGroup().location]"
}
Resources
The resources
section defines the Azure resources to be deployed.
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "[variables('storageAccountName')]",
"location": "[variables('location')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "StorageV2"
}
]
Outputs
Outputs return values from your deployment, such as connection strings or IP addresses.
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
Deployments
You can deploy ARM templates using various methods:
- Azure Portal: Navigate to "Deployments" -> "Add" and upload your template.
- Azure CLI:
az deployment group create --resource-group MyResourceGroup --template-file azuredeploy.json
- Azure PowerShell:
New-AzResourceGroupDeployment -ResourceGroupName "MyResourceGroup" -TemplateFile "azuredeploy.json"
ARM REST API
The Azure Resource Manager REST API allows programmatic interaction with Azure resources. You can use it to create, retrieve, update, and delete resources.
Example: Creating a resource group:
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}?api-version=2021-04-01
Content-Type: application/json
{
"location": "eastus",
"tags": {
"environment": "dev"
}
}
Azure CLI Commands
The Azure CLI provides a powerful command-line interface for managing Azure resources.
az group create --name MyResourceGroup --location eastus
az deployment group create --resource-group MyResourceGroup --template-file template.json
az resource list --resource-group MyResourceGroup
SDKs
Azure SDKs are available for various programming languages (Python, .NET, Java, Node.js, Go) to interact with ARM programmatically.
Refer to the official Azure SDK documentation for specific examples.