ARM Template Development

Within this article, scope of “Azure Marketplace” is limited to China.

Azure Resource Manager (ARM) is Azure’s deployment and management service. It provides a consistent management layer that can be used to create, update, and delete resources within Azure subscriptions. After deployment, you can use ARM’s access control, audit, and tagging functions to protect and organize resources.

1. Quickly create ARM templates

1.1 Understanding the basic concepts behind ARM

See Azure Resource Manager Overview for an overview of basic information about ARM.

1.2 Quick start

2. Example ARM templates

2.1 Resource API syntax in ARM templates

Please refer to Define resources in Azure Resource Manager templates. In the following figure you can view information about the Reference Node Resource API.

Please note that the resource information above is based on the global Azure Marketplace, but the resource types and specific definitions for Azure China Marketplace may vary slightly. As resource APIs undergo a process of dynamic updates, you generally need to use the latest version. You can manually check the resource version number from the Azure China Portal (All Services -> Resource Browser), as shown below.

At the same time, we recommend using the resource function to dynamically get the latest API Version information, see Azure Resource Manager template functions: providers resource function. For example, you can get the API version of the storage account using the following method:

"apiVersion": "[providers('Microsoft.Storage','storageAccounts').apiVersions[0]]"

2.2 There are many ARM template examples you can use as references.

Azure quick start template sample and Azure quick start template sample file.

Please note: If you cannot run PowerShell scripts downloaded locally from the website it may be because of Windows Security Isolation. You can select “unblock” from the script file attribute page. This will unlock the file and then run it again.

2.3 ARM template best practice

Please refer to the ARM Template Best Practice Guide

3. Important points for ARM template development

3.1 VM login credential method

In addition to supporting virtual machine login user name and password, we strongly recommend at the same time supporting credentials or SSH key login. Please refer to the certificate and OSProfile sections of the Azure virtual machine scale sets FAQs and the examples in the 101-vm-sshkey GitHub quick start template.

3.2 Resource dependencies

The ARM template is resource-centric, so you need to pay special attention to the dependencies between resources and understand the order in which processes are generated by these resources. For example, you can set up an ARM template for the website in Azure (see the sample WordPress ARM template in the Azure portal):

  • The connection test process (type "config") dependsOn PHP configuration (type "config");

  • PHP configuration dependsOn PHP software installation (type "extensions");

  • PHP software installation depends on the website (type "Microsoft.Web/sites/").

    In the use cases above, it is sometimes still possible to successfully create a website without having strict resource dependencies, but the site is likely to be unstable and subject to frequent failures with causes that are difficult to identify.

    For how to use these dependencies refer to Define the order for deploying resources in Azure Resource Manager templates.

3.3 Extensions issues

You often need to use Extensions scripts in ARM and because Extensions scripts are implemented when a virtual machine is created, scripts often need to be downloaded and implemented on the network. If the script is on an external Web (like GitHub), in practice it is often easy for the download to fail or run slowly. Because of this, we recommend putting the scripts on the Azure Cloud Platform.

3.4 VHD image references

If your ARM template refers to a VHD image, you must first publish the image on the Azure Marketplace publication platform (unlike the normal image publication process, hidden publication means that you only need to select “Hide this SKU” when publishing the image’s SKU. Though the image has been published, it is not displayed in the Azure portal or Azure Marketplace). Once the image is published, you need to obtain the published image information from the Azure Marketplace support personnel or confirm that the image has been published using the following PowerShell commands:

  • Get all publishers in the Azure Marketplace: Get-AzureRmVMImagePublisher

  • Get all offers published by the publisher: Get-AzureRmVMImageOffer

  • Get all SKUs for an offer: Get-AzureRmVMImageSku

  • Get all versions of an SKU image: Get-AzureRmVMImage

  • For example:

      Get-AzureRmVMImage `
      -Location "china north" `
      -PublisherName "redcore" `
      -offer "endome" `
      -skus "standard"
    

The ARM template must contain the following four items:

"storageProfile": {
    "imageReference": {
        "publisher": "abcpublisher",
        "offer": "abcimage",
        "sku": "standard",
        "version": "latest"
    }
}

3.5 Migrate ARM Templates From the Global Azure Marketplace to the Azure China Marketplace

As Azure China cloud computing centers operate separately from the global Azure platform, while the development of ARM templates remains broadly the same for the global and China versions, there are some small differences in the support for a minority of resources. As a result, you need to perform compatibility testing and pay particular attention to the points below.

In section 2, resources in some ARM templates are not supported in Azure China Portal.      
Please refer to the Azure China portal in section 2 (All Services -> Resource Browser).      
In section 2, in addition to the "imageReference" for VHD, Azure China Portal does not support the "plan" field.      
The "plan" field is also not required for images that reference the Azure China MarketPlace in ARM templates.

Next steps

Feedback

  • If you have any questions about this documentation, please submit user feedback in the Azure Marketplace.
  • You can also look for solutions in the FAQs.