ARM UI and ARM Template Testing

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

1. ARM UI Testing

In this section, we will use sample files to demonstrate how to test user interfaces.

1.1 Prerequisites

1.2 Run the Test Script

To see your interface file in the portal, run your downloaded script. The script creates a storage account in your Azure subscription (one won’t be created if it already exists), and uploads your createUiDefinition.json file to the storage account. The script then opens the portal and loads your file from the storage account.

Execute the script, providing a location for the storage account and specifying the folder that has your createUiDefinition.json file in the parameters.

Method 1: Use PowerShell. First sign in to Azure, then execute the following script:

.\SideLoad-CreateUIDefinitionChina.ps1 `
-StorageResourceGroupLocation chinanorth `
-ArtifactsStagingDirectory .\Marketplace-uisample

or

.\SideLoad-CreateUIDefinitionChina.ps1   //A storage account has been created, createUiDefinition.json and script are in the same directory

Please note that if you cannot run the PowerShell script, it may be because of Windows Security Isolation. Select “unblock” from the script file attributes page to unblock the file, then run the script again.

Method 2: Use the Azure CLI. First sign in to Azure, then execute the following script:

./sideload-createuidef.sh -l chinanorth -a .\Marketplace-uisample

or

./sideload-createuidef.sh  //A storage account has been created, createUiDefinition.json and script are in the same directory

1.3 View the Test Interface

The script opens a new tab in your browser. It displays the portal with your interface for creating the managed application, as shown below.

Before filling out the fields, open the “Web Developer Tools” in your browser. The “Console” displays important messages about your interface (press F12 if you are using the Microsoft Edge browser). If your interface definition has an error, you see the description in the console.

Provide values for the fields in the portal. When finished, you will see the values that have been passed to the template, as shown below. Save these parameters as a parameter file such as exampletemplate.parameters.json. In Section 4, you will use this parameter file to test the template deployment.

1.4 Troubleshooting Interface Issues

Some common errors you might see are:

  • The portal doesn't load your interface. Instead, it shows an icon of a cloud with tear drop. Usually, you see this icon when there's a syntax error in your file. Open the file in VS Code (or other JSON editor that has schema validation) and look for syntax errors.
  • The portal hangs at the summary screen. Usually, this interruption happens when there's a bug in the output section. For example, you may have referenced a control that does not exist.
  • A parameter in the output is empty. The parameter might be referencing a property that doesn't exist. For example, the reference to the control is valid, but the property reference isn't valid.

2. Integration Testing for ARM Templates and the createUiDefinition UI file

Method 1: Copy the template parameters in Section 1.3 into a parameter file for testing

This method is simpler. This method uses the ARM template file and createUiDefinition to test the generated parameter file. It uses these parameters to deploy the template, and validates the correctness of createUiDefinition by testing whether the parameters are correct. If your template file is called exampletemplate.json and the parameters file is called exampletemplate.parameters.json, in PowerShell, you would do the following:

New-AzureRmResourceGroup -Name ExampleResourceGroup -Location "China North"

New-AzureRmResourceGroupDeployment `
-Name ExampleDeployment `
-ResourceGroupName ExampleResourceGroup `
-TemplateFile c:\MyTemplates\exampletemplate.json `
-TemplateParameterFile c:\MyTemplates\exampletemplate.parameters.json

or

Test-AzureRmResourceGroupDeployment `
-ResourceGroupName ExampleResourceGroup `
-TemplateFile c:\MyTemplates\exampletemplate.parameters.json `
-storageAccountType Standard_GRS

For details, see the “Parameter Files” or “Test Template Deployment” sections in Using PowerShell to Deploy an ARM Template.

Method 2: Integrate the createUiDefinition file with the ARM Template file

After verifying your portal interface is working as expected, you can validate that your createUiDefinition file is properly integrated with your mainTemplate.json file. You can run a validation script test to test the content of your solution files, including the createUiDefinition file. The script validates the JSON syntax, checks for regex expressions on text fields, and makes sure the output values of the portal interface match the parameters of your template. For information on running this script, see Run static validation checks for 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.