Skip to content

Azure Resource Manager

For if you are creating a virtual machine, you will send our inputs to the Azure Resource Manager, and ARM will forward the request to Microsoft.Compute Compute resource provider after validation. The resource provider will deploy the resource and update you with the status via ARM. Similarly, when you create a networking resource like a virtual network, the resource provisioning is done by the Microsoft.Network resource provider.

Note

  • Resource groups is a feature of ARM
  • ARM is not only responsible for the deployment of the resources, but also responsible for the management of resources.

Template File

In its simplest structure, a template has the following elements:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "",
  "apiProfile": "",
  "parameters": {  },
  "variables": {  },
  "functions": [  ],
  "resources": [  ],
  "outputs": {  }
}

Required values are

  • $Schema
  • contentVersion
  • resources

The template has the following sections:

Template sections

  • $schema: Location of the JSON schema file that describes the version of the template language. The version number you use depends on the scope of the deployment and your JSON editor.
  • contentVersion: Version of the template (such as 1.0.0.0). You can provide any value for this element. Use this value to document significant changes in your template. When deploying resources using the template, this value can be used to make sure that the right template is being used.
  • apiProfile; An API version that serves as a collection of API versions for resource types. Use this value to avoid having to specify API versions for each resource in the template. When you specify an API profile version and don't specify an API version for the resource type, Resource Manager uses the API version for that resource type that is defined in the profile.
  • Parameters - Provide values during deployment/runtime that allow the same template to be used with different environments.
  • Variables - Define values that are reused in your templates. They can be constructed from parameter values.
  • User-defined functions - Create customized functions that simplify your template.
  • Resources - Specify the resources to deploy.
  • Outputs - Return values from the deployed resources.

Deployment mode

  • Complete mode: In this mode, RM deletes resources that exist in the resource group but aren't specified in the template.

Always use the what-if operation before deploying a template in complete mode. What-if shows you which resources will be created, deleted, or modified. Use what-if to avoid unintentionally deleting resources.

  • Incremental mode: In this mode the RM leaves unchanged resources that exist in the resource group but aren't specified in the template. Resources in the template are added to the resource group.

Example

To illustrate the difference between incremental and complete modes, consider the following scenario.

Resource Group contains:
    -  Resource A
    -  Resource B
    -  Resource C

Template contains:
    - Resource A
    - Resource B
    - Resource D

When deployed in incremental mode, the resource group has:
    - Resource A
    - Resource B
    - Resource C
    - Resource D

When deployed in complete mode, Resource C is deleted. The resource group has:
    - Resource A
    - Resource B
    - Resource D

Deployment Scope

Scope of deployment can be

  1. Management Group
  2. Subscription
  3. Resource Group
  4. Tenant
  5. Extension resource: An extension resource is a resource that modifies another resource. For example, you can assign a role to a resource. The role assignment is an extension resource type.

You can target your deployment to a resource group, subscription, management group, or tenant. Depending on the scope of the deployment, you use different commands.

There is no resource level scope

create various resources using powershell
# To create an Azure resource, such as a website, Azure SQL Database server, or Azure SQL Database, in a resource group use:
New-AzResource 

# To add a deployment to an existing resource group, use:
New-AzResourceGroupDeployment 

# The New-AzDeployment cmdlet adds a deployment at the current subscription scope. This includes the resources that the deployment requires.
New-AzDeployment 

What-ifs

ARM provides the what-if operation to let you see how resources will change if you deploy the template. The what-if operation doesn't make any changes to existing resources. Instead, it predicts the changes if the specified template is deployed.

Resource Dependency

When deploying resources, you may need to make sure some resources exist before other resources. For example, you need a logical SQL server before deploying a database. You establish this relationship by marking one resource as dependent on the other resource. Use the dependsOn element to define an explicit dependency. Use the reference or list functions to define an implicit dependency.

NIC dependency a VNET, NSG, and public IP
{
    "type": "Microsoft.Network/networkInterfaces",
    "apiVersion": "2020-06-01",
    "name": "[variables('networkInterfaceName')]",
    "location": "[parameters('location')]",
    "dependsOn": [
      "[resourceId('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
      "[resourceId('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
      "[resourceId('Microsoft.Network/publicIpAddresses/', variables('publicIpAddressName'))]"
    ],
    ...
}

Was this page helpful?
-->