createUiDefinition.json için test çalışmaları

Bu makalede, createUiDefinition.json dosyaları için şablon test araç seti ile çalıştırılacak testler açıklanmaktadır. Örnekler, testleri geçiren veya başarısız olan test adlarını ve kod örneklerini içerir.

Araç seti, Azure Resource Manager şablonları (ARM şablonları) için test çalışmalarını ve azuredeploy.json veya maintemplate.json adlı ana şablon dosyalarını içerir. Dizin bir createUiDefinition.json dosyası içerdiğinde, kullanıcı arabirimi denetimleri için belirli testler çalıştırılır. Testleri çalıştırma veya belirli bir testi çalıştırma hakkında daha fazla bilgi için bkz . Test parametreleri.

createUiDefinition.json dosyası, öğeleri ve işlevleri kullanarak özel kullanıcı arabirimi (UI) denetimleri oluşturur.

Şablon parametresinin değerlere izin verdiğinden emin olun

Test adı: İzin Verilen Değerlere Gerçekten İzin Verilmelidir

Bu test, ana şablonun parametrelerinde createUiDefinition.json her denetim için değerlere izin verildiğini denetler. Parametreler, ana şablon ile createUiDefinition.json dosyası arasında ada göre eşlenir.

Ana şablonun parametresi, denetimin allowedValuesdeğerindeki değerleri kabul etmelidir. Test ayrıca createUiDefinition.json outputs bölümünde denetime başvurulduğunu denetler.

Bu test ana şablonu ve createUiDefinition.json dosyasını denetler. Ana şablon örneklerinden sonra createUiDefinition.json dosyası örneği gösterilir.

Ana şablonun parametre adı denetimin parametre adıyla eşleşmediğinden aşağıdaki örnek başarısız oluyor.combo comboBox

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "combo": {
      "type": "string",
      "defaultValue": "two"
    }
  },
  "resources": [],
  "outputs": {
    "comboBoxOutput": {
      "type": "string",
      "value": "[parameters('combo')]"
    }
  }
}

Ana şablonun parametre türü denetimin string değerini kabul etmediğinden aşağıdaki örnek başarısız olur.int Bir ana şablonun parametresi bir defaultValue tanımlıyorsa, denetimin allowedValuesiçinde geçerli value olması gerekir.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "comboBox": {
      "type": "int",
      "defaultValue": 4
    }
  },
  "resources": [],
  "outputs": {
    "comboBoxOutput": {
      "type": "string",
      "value": "[parameters('combo')]"
    }
  }
}

Ana şablonun parametre adı denetimin parametre adıyla eşleştiğinden aşağıdaki örnek geçer . Şablonun parametre türü, string denetimin allowedValuesiçinde belirtilen ile defaultValue olur.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "comboBox": {
      "type": "string",
      "defaultValue": "two"
    }
  },
  "resources": [],
  "outputs": {
    "comboBoxOutput": {
      "type": "string",
      "value": "[parameters('comboBox')]"
    }
  }
}

Bu örneğin createUiDefinition.json dosyası:

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [],
    "steps": [
      {
        "name": "demoComboBox",
        "label": "demoComboBoxLabel",
        "elements": [
          {
            "name": "comboBox",
            "type": "Microsoft.Common.DropDown",
            "label": "Example drop down",
            "defaultValue": "Value two",
            "toolTip": "This is a tool tip",
            "constraints": {
              "allowedValues": [
                {
                  "label": "Value one",
                  "description": "The value to select for option 1.",
                  "value": "one"
                },
                {
                  "label": "Value two",
                  "description": "The value to select for option 2.",
                  "value": "two"
                }
              ],
              "required": true
            },
            "visible": true
          }
        ]
      }
    ],
    "outputs": {
      "comboBox": "[steps('demoComboBox').comboBox]"
    }
  }
}

Çıkış denetimleri mevcut olmalıdır

Test adı: Çıkışlardaki Denetimler Mevcut Olmalıdır

bölümünde kullanılan outputs denetimlerin createUiDefinition.json başka bir yerdeki bir öğede bulunması gerekir. içinde outputs başvuruda bulunan ad veya steps[]içinde basics[] kullanılan bir adla eşleşmelidir.

Aşağıdaki örnek başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "nameDoesNotMatchOutput",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]"
    }
  }
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]"
    }
  }
}

Özellikler değer içermelidir

Test adı: CreateUIDefinition Boş Olmamalıdır

Özellikler değerleri içermelidir. Gerekli özellikler geçerli değerler kullanmalıdır. Boş olan isteğe bağlı özellikler kaldırılmalıdır. Test boş "basics": [], "steps": []veya defaultValueizin verir.

Aşağıdaki örnek , placeholderve toolTip boş olduğundan labelbaşarısız olur.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "",
        "placeholder": "",
        "defaultValue": "",
        "toolTip": ""
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]"
    }
  }
}

Aşağıdaki örnek, ve değerlerine sahip olduğundan label toolTip ve placeholder kaldırıldığından geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "defaultValue": "",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]"
    }
  }
}

Geçerli şemayı ve sürümü kullanma

Test adı: CreateUIDefinition şemasına sahip olmalıdır

createUiDefinition.json dosyası bir $schema özellik içermeli ve geçerli $schema ve versionkullanmalıdır. ve içindeki $schema version sürüm numaraları eşleşmelidir.

Aşağıdaki örnek başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.9.9-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.9.9-preview"
}

Aşağıdaki örnek, en son $schema ve versionkullandığından geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview"
}

Kimlik bilgisi onaylarını gizleme

Test adı: Kimlik Bilgisi Onayı Gizli Olmamalıdır

Bu test, Microsoft.Common.PasswordBox veya Microsoft.Compute.CredentialsCombo için kimlik bilgilerinin onaylandığını denetler. Onay hideConfirmation görünür olacak şekilde özelliği olarak ayarlanmalıdır false .

Aşağıdaki örnek, olduğu trueiçin hideConfirmation başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "credentials",
        "type": "Microsoft.Compute.CredentialsCombo",
        "label": {
          "password": "Password",
          "confirmPassword": "Confirm password"
        },
        "toolTip": {
          "password": "Type your credentials"
        },
        "constraints": {
          "required": true,
          "customPasswordRegex": "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{12,}$",
          "customValidationMessage": "The password must be alphanumeric, contain at least 12 characters, and have at least 1 letter and 1 number."
        },
        "options": {
          "hideConfirmation": true
        },
        "osPlatform": "Windows",
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "credentials": "[basics('credentials')]"
    }
  }
}

Aşağıdaki örnek, olduğu falseiçin hideConfirmation geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "credentials",
        "type": "Microsoft.Compute.CredentialsCombo",
        "label": {
          "password": "Password",
          "confirmPassword": "Confirm password"
        },
        "toolTip": {
          "password": "Type your credentials"
        },
        "constraints": {
          "required": true,
          "customPasswordRegex": "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{12,}$",
          "customValidationMessage": "The password must be alphanumeric, contain at least 12 characters, and have at least 1 letter and 1 number."
        },
        "options": {
          "hideConfirmation": false
        },
        "osPlatform": "Windows",
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "credentials": "[basics('credentials')]"
    }
  }
}

Doğru işleyiciyi kullanma

Test adı: İşleyici Doğru Olmalıdır

createUiDefinition.json dosyasında veya Microsoft.Compute.MultiVm kullanınMicrosoft.Azure.CreateUIDef.

Aşağıdaki örnek başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.",
  "version": "0.1.2-preview"
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview"
}

Mevcut kaynakları gizleme

Test adı: HideExisting Doğru İşlenmelidir

olarak ayarlanırsa hideExisting false veya atlanırsa ve outputs newOrExistingiçermelidirresourceGroup. için hideExisting varsayılan değeridir false.

Microsoft.Storage.StorageAccountSelector, Microsoft.Network.PublicIpAddressCombo veya Microsoft.Network.VirtualNetworkCombo gibi hideExisting denetim türlerine örnek verilebilir.

Aşağıdaki örnek başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "storage",
        "type": "Microsoft.Storage.StorageAccountSelector",
        "label": "Storage account",
        "toolTip": "This is a demo storage account",
        "defaultValue": {
          "name": "storageaccount01",
          "type": "Premium_LRS"
        },
        "options": {
          "hideExisting": false
        },
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]"
    }
  }
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "storage",
        "type": "Microsoft.Storage.StorageAccountSelector",
        "label": "Storage account",
        "toolTip": "This is a demo storage account",
        "defaultValue": {
          "name": "storageaccount01",
          "type": "Premium_LRS"
        },
        "options": {
          "hideExisting": false
        },
        "visible": false
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "resourceGroup": "[basics('storage').resourceGroup]",
      "newOrExisting": "[basics('storage').newOrExisting]"
    }
  }
}

Çıkışlarda konum kullanma

Test adı: Konum Çıkışlarda Olmalıdır

bölümü location outputs işlevini kullanan bir konum içermelidir.

Aşağıdaki örnek bir konum içermediğinden başarısız oluroutputs.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]"
    }
  }
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]",
      "location": "[location()]"
    }
  }
}

Şablon parametrelerine denetim çıkışlarını ekleme

Test adı: Çıkışlar Şablon Parametrelerinde Mevcut Olmalıdır

Test, createUiDefinition.json bir bölüm içerdiğini outputs denetler. Test ayrıca bunların outputs ana şablonun parameters bölümünde tanımlandığını denetler. Parametreler createUiDefinition.json ve ana şablon arasında ada göre eşlendiğinden adların eşleşmesi gerekir.

Bu test ana şablonu ve createUiDefinition.json dosyasını denetler. Ana şablon örneklerinden sonra createUiDefinition.json dosyası örneği gösterilir.

Ana şablon createUiDefinition.json dosyasının outputs bölümünden comboBox parametresini içermediğinden aşağıdaki örnek başarısız olur.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    }
  },
  "resources": [],
  "outputs": {
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    }
  }
}

Aşağıdaki örnek, ana şablon parametresini içerdiğinden comboBox geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "comboBox": {
      "type": "string",
      "defaultValue": "two"
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    }
  },
  "resources": [],
  "outputs": {
    "comboBox": {
      "type": "string",
      "value": "[parameters('comboBox')]"
    },
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    }
  }
}

Bu örneğin createUiDefinition.json dosyası:

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]",
      "location": "[location()]"
    }
  }
}

Çıkışlarda varsayılan olmayan parametreler bulunmalıdır

Test adı: CreateUIDefinition'da Varsayılan Olmayan Parametreler Bulunmalıdır

Varsayılan değeri olmayan ana şablondaki parametreler createUiDefinition.json dosyasının outputs bölümünde bulunmalıdır.

Bu test ana şablonu ve createUiDefinition.json dosyasını denetler. denetimin örneklerinden sonra azuredeploy.json dosyası örneği gösterilir.

aşağıdaki örnek, createUiDefinition.json dosyasının outputs ana şablonun parametresini comboBoxiçermediğinden başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]"
    }
  }
}

aşağıdaki örnek, createUiDefinition.json içinde outputsöğesini içerdiğinden comboBox geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "comboBox": "[basics('comboBox')]",
      "location": "[location()]"
    }
  }
}

Bu örnek için azuredeploy.json dosyası. Parametresinin comboBox varsayılan değeri yok.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "comboBox": {
      "type": "string"
    },
    "location": {
      "type": "string"
    }
  },
  "resources": [],
  "outputs": {
    "comboBox": {
      "type": "string",
      "value": "[parameters('comboBox')]"
    },
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    }
  }
}

Parola kutusuyla güvenli parametre kullanma

Test adı: Parola parametreleri için parola metin kutuları kullanılmalıdır

Bu test, bir Microsoft.Common.PasswordBox öğesinin ana şablonun parameters ve createUiDefinition.json outputs tanımlandığını denetler. Parola kutusu için ana şablonun parametre türü veya secureObjectolmalıdırsecureString.

Bu test ana şablonu ve createUiDefinition.json dosyasını denetler. Ana şablon örneklerinden sonra createUiDefinition.json dosyası örneği gösterilir.

Ana şablonun parametresi bir stringolduğundan aşağıdaki örnek başarısız oluyor.passwordBox

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "passwordBox": {
      "type": "string"
    },
    "location": {
      "type": "string"
    }
  },
  "resources": [],
  "outputs": {
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    }
  }
}

Aşağıdaki örnek, ana şablonun passwordBox parametresi bir secureStringolduğundan geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "passwordBox": {
      "type": "secureString"
    },
    "location": {
      "type": "string"
    }
  },
  "resources": [],
  "outputs": {
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    }
  }
}

Bu örneğin createUiDefinition.json dosyası:

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "passwordBox",
        "type": "Microsoft.Common.PasswordBox",
        "label": {
          "password": "Password",
          "confirmPassword": "Confirm password"
        },
        "toolTip": "Type a password"
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "passwordBox": "[basics('passwordBox')]"
    }
  }
}

Parola kutusu en az uzunluk gerektirir

Test adı: PasswordBox'ların uzunluğu en az olmalıdır

Test, Microsoft.Common.PasswordBox öğesinin en az 12 karakter gerektiren bir regex ile birlikte kullandığını constraints denetler.

Aşağıdaki örnek, olmadığından constraintsbaşarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "passwordBox",
        "type": "Microsoft.Common.PasswordBox",
        "label": {
          "password": "Password",
          "confirmPassword": "Confirm password"
        },
        "toolTip": "Type a password"
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "passwordBox": "[basics('passwordBox')]"
    }
  }
}

Aşağıdaki örnek, en az 12 karakter gerektirdiğinden regex geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "passwordBox",
        "type": "Microsoft.Common.PasswordBox",
        "label": {
          "password": "Password",
          "confirmPassword": "Confirm password"
        },
        "toolTip": "Type a password",
        "constraints": {
          "required": true,
          "regex": "^[a-zA-Z0-9]{12,}$",
          "validationMessage": "Password must be at least 12 characters long, contain only numbers and letters"
        }
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "passwordBox": "[basics('passwordBox')]"
    }
  }
}

Metin kutusu doğrulama kullanmalıdır

Test adı: Metin Kutuları İyi Biçimlendirilmiş

ve messageiçerenleri regex denetlemek için constraints metin kutularıyla doğrulamayı kullanın.

Aşağıdaki örnek başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "textBox",
        "type": "Microsoft.Common.TextBox",
        "label": "Text box",
        "toolTip": "Type 1-30 alphanumeric characters",
        "placeholder": "Type your text here",
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "textBox": "[basics('textBox')]"
    }
  }
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "textBox",
        "type": "Microsoft.Common.TextBox",
        "label": "Text box",
        "toolTip": "Type 1-30 alphanumeric characters",
        "placeholder": "Type your text here",
        "constraints": {
          "required": true,
          "validations": [
            {
              "regex": "^[a-z0-9A-Z]{1,30}$",
              "message": "Only 1-30 characters alphanumeric characters are allowed."
            }
          ]
        },
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "textBox": "[basics('textBox')]"
    }
  }
}

araç ipucu bir değerle mevcut olmalıdır

Test adı: Araç İpuçları Mevcut Olmalıdır

Bu test özelliğin toolTip mevcut olup olmadığını denetler ve bir değer içerir.

Aşağıdaki örnek başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": ""
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "comboBox": "[basics('comboBox')]"
    }
  }
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "comboBox",
        "type": "Microsoft.Common.DropDown",
        "label": "Example drop down",
        "toolTip": "This is a tool tip"
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "comboBox": "[basics('comboBox')]"
    }
  }
}

Varsayılan kullanıcı adı ayarlama

Test adı: Kullanıcı adlarının varsayılan değeri olmamalıdır

Test, Microsoft.Compute.UserNameTextBox için bir defaultValue küme olup olmadığını denetler.

Aşağıdaki örnek, sağlandığından defaultValue başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "userNameBox",
        "type": "Microsoft.Compute.UserNameTextBox",
        "label": "User name",
        "defaultValue": "admin",
        "toolTip": "Enter your user name",
        "osPlatform": "Windows"
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "userNameBox": "[basics('userNameBox')]"
    }
  }
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "userNameBox",
        "type": "Microsoft.Compute.UserNameTextBox",
        "label": "User name",
        "toolTip": "Enter your user name",
        "osPlatform": "Windows"
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "userNameBox": "[basics('userNameBox')]"
    }
  }
}

doğrulamalarla ileti kullanma

Test adı: Doğrulamaların İletisi Olmalıdır

Bu test, createUiDefinition.json içindeki herhangi bir validations öğesinin bir messageiçermediğini denetler.

Doğrulamada bir olmadığından aşağıdaki örnek başarısız oluyor.messageregex

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "textBox",
        "type": "Microsoft.Common.TextBox",
        "label": "Text box",
        "toolTip": "Type 1-30 alphanumeric characters",
        "placeholder": "Type your text here",
        "constraints": {
          "required": true,
          "validations": [
            {
              "regex": "^[a-z0-9A-Z]{1,30}$"
            }
          ]
        },
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "textBox": "[basics('textBox')]"
    }
  }
}

Aşağıdaki örnek geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "textBox",
        "type": "Microsoft.Common.TextBox",
        "label": "Text box",
        "toolTip": "Type 1-30 alphanumeric characters",
        "placeholder": "Type your text here",
        "constraints": {
          "required": true,
          "validations": [
            {
              "regex": "^[a-z0-9A-Z]{1,30}$",
              "message": "Only 1-30 characters alphanumeric characters are allowed."
            }
          ]
        },
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "textBox": "[basics('textBox')]"
    }
  }
}

Sanal makine boyutları eşleşmelidir

Test adı: VM Boyutları Şablonla Eşleşmelidir

Bu test, Microsoft.Compute.SizeSelector dosyasının createUiDefinition.json outputs ve ana şablonun bölümünde olup olmadığını parameters denetler. belirten defaultValue ana şablon parametreleri, denetimin allowedSizesiçindeki bir değerle eşleşmelidir.

Bu test ana şablonu ve createUiDefinition.json dosyasını denetler. Ana şablon örneklerinden sonra createUiDefinition.json dosyası örneği gösterilir.

Aşağıdaki örnek, ana şablonun defaultValue içindeki allowedSizesbir değerle eşleşmediğinden başarısız oluyor.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "type": "string"
    },
    "vmSize": {
      "type": "string",
      "defaultValue": "Standard_D9"
    }
  },
  "resources": [],
  "outputs": {
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    },
    "vmSize": {
      "type": "string",
      "value": "[parameters('vmSize')]"
    }
  }
}

Aşağıdaki örnek, ana şablonun defaultValue içindeki allowedSizesbir değerle eşleştiğinden geçer.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "type": "string"
    },
    "vmSize": {
      "type": "string",
      "defaultValue": "Standard_D3"
    }
  },
  "resources": [],
  "outputs": {
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    },
    "vmSize": {
      "type": "string",
      "value": "[parameters('vmSize')]"
    }
  }
}

Bu örneğin createUiDefinition.json dosyası:

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "name": "vmSize",
        "type": "Microsoft.Compute.SizeSelector",
        "label": "VM Size",
        "toolTip": "Select a virtual machine size",
        "recommendedSizes": [
          "Standard_D1"
        ],
        "constraints": {
          "allowedSizes": [
            "Standard_D1",
            "Standard_D2",
            "Standard_D3"
          ]
        },
        "osPlatform": "Windows",
        "visible": true
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "vmSize": "[basics('vmSize')]"
    }
  }
}

Sonraki adımlar