referenceType metadata for parameters in Azure ARM template

Cloud administrators can define referenceType metadata in an Azure ARM template. Each parameter with referenceType metadata references a ServiceNow Resource Type table entry. On the catalog ordering page, the variable type for these parameters becomes a Reference. This feature makes Azure resource group catalog ordering less error-prone.

The following is an example to define referenceType metadata for each parameter in an Azure ARM template.

"parameters": {   
        "vnetName": {        
        "type": "string",        
        "defaultValue": "testdummyvnet",
        "minLength": 9,
        "maxLength": 39,
        "metadata": {    
          "description":"...",
          "SNC::Parameter::Metadata": {
              "constraintDescription":"Please provide a valid vnetName",
              "referenceType":"Microsoft.Network/virtualNetworks",          
              "allowedPattern":"[0-9a-zA-Z]+"} 
          }
        },
        "password": {        
        "type": "securestring",        
        "defaultValue": "testfordummy",
        "minLength": 8,
        "maxLength": 25,
        "metadata": {    
          "description":"...",
          "SNC::Parameter::Metadata": {
             "constraintDescription":"Please provide a valid password",
             "allowedPattern":"[0-9a-zA-Z]+"} 
         }
        },
        "storagedisksize": {        
        "type": "int",        
        "defaultValue": "testfordisksize",
        "minValue": 3,
        "maxValue": 9,
        "metadata": {    
          "description":"...",
          "SNC::Parameter::Metadata": {
             "constraintDescription":"Please provide a valid disk size",
             "referenceType":"storage:disksize",          
             "allowedPattern":"[0-9]+"} 
         }
        },
        "virtualnetworkname": {        
        "type": "array",        
        "defaultValue": "testfornetworkname",
        "minLength": 1,
        "maxLength": 10,
        "metadata": {    
          "description":"...",
          "SNC::Parameter::Metadata": {
             "referenceType":"Microsoft.Network/virtualNetworks",          
             "allowedPattern":"[0-9a-zA-Z]+"} 
         }
        }
      }

To define a password parameter, use the secureString parameter. In this example, if the admin sets the type as secureString, then referenceType is ignored and the corresponding catalog variable has the Reenter text box on the catalog order page.

When the admin creates referenceType metadata, the following table is created to associate a reference for the given type.

Table 1. Template Parameter Type
Name Description
Name Matches the referenceType in the template metadata. Example: user name.
Resource Type Reference to cloud resource type table pointing to appropriate resource type record. Example: region.
Table Field Populated based on template parameter in the Resource Type table. Example: size.
Resource Table Populates the name of the table derived from the Resource Type field. The cloud user does not see this field: if the specified Resource Type does not exist in the cloud resource type, then the cloud user must explicitly fill in this field on the order form. Example: user name, region, size.

To reference an Azure image using referenceType metadata, the publisher, offer, and SKU for that image must always be specified. If the version is not also specified, then the last known will be used. Cloud admins can employ these templates to create an image variable containing these parameters. This variable automatically populates the provided information for a requested VM, thus simplifying the ordering process for a cloud user.

The following is an example to define image referenceType metadata in an ARM template, and creates a group variable called image1.

"imageOffer": {           
        "type": "string",           
        "metadata": {             
        "description": "image offer",   
        "SNC::Parameter::Metadata": {                 
        "groupKey":"image1",              
        "referenceType" :"Microsoft.Compute/Images::Offer" }         
        }     
        },    
"imagePublisher": {           
        "type": "string",           
        "metadata": {             
        "description": "image publisher",        
        "SNC::Parameter::Metadata": {            
        "groupKey":"image1",              
        "referenceType" :"Microsoft.Compute/Images::Publisher" }           
        }     
        },
      

Metadata for image resource type must contain both referenceType and groupKey to utilize image reference. Parameters with groupKey are hidden on the catalog order page. If the parameter metadata contains only referenceType, then a group variable is not created and the variable shows on the catalog order page. Removing all parameters with the groupKey metadata removes the group variable.

If you encounter a template validation error, then make sure that:

  • The groupKey value differs from the name of its parameter. These two values must not be identical.
  • The prefix used in referenceType (the part before the ::) is the same for all parameters that have the same groupKey value.