createUiDefinition.json için test çalışmaları
Bu makalede createUiDefinition.json dosyaları için şablon testi araç seti ile çalıştırılacak testler açıklanmaktadır. Örnekler, test adlarını ve testlerden geçen veya başarısız olan 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 dosyasındaki 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 allowedValues
değerindeki değerleri kabul etmelidir. Test ayrıca createUiDefinition.jsonoutputs
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ının bir örneği gösterilir.
Ana şablonun parametre adı denetimin parametre adıyla combo
comboBox
eşleşmediğ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": {
"combo": {
"type": "string",
"defaultValue": "two"
}
},
"resources": [],
"outputs": {
"comboBoxOutput": {
"type": "string",
"value": "[parameters('combo')]"
}
}
}
Ana şablonun parametre türü int
denetimin string
değerini kabul etmediğinden aşağıdaki örnek başarısız olur. Bir ana şablonun parametresi bir defaultValue
tanımlıyorsa, denetimin allowedValues
içinde geçerli value
olmalıdır.
{
"$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ü, denetimin içinde belirtilen ile defaultValue
bir değeridir.string
allowedValues
{
"$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 örnek iç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 outputs
kullanılan denetimlerin createUiDefinition.json dosyasının başka bir yerinde bir öğede bulunması gerekir. içinde outputs
başvuruda bulunan ad, veya steps[]
içinde basics[]
kullanılan adla eşleşmelidir.
Aşağıdaki örnek baş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": "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ğer 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 defaultValue
izin verir.
Aşağıdaki örnek, , placeholder
ve toolTip
boş olduğundan label
baş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 toolTip
değerlerine sahip olduğundan label
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 şema 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
version
ve kullanmalıdır. ve version
içindeki $schema
sürüm numaraları eşleşmelidir.
Aşağıdaki örnek başarısız olur.
{
"$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 version
kullandığı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 true
iç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 false
iç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 olur.
{
"$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
newOrExisting
içermelidirresourceGroup
. için hideExisting
varsayılan değeridir false
.
Microsoft.Storage.StorageAccountSelector, Microsoft.Network.PublicIpAddressCombo veya Microsoft.Network.VirtualNetworkCombo denetim hideExisting
türlerine örnek olarak verilebilir.
Aşağıdaki örnek baş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": "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
createUiDefinition.json test denetimleri bir outputs
bölüm içerir. Test ayrıca bunların outputs
ana şablonun parameters
bölümünde tanımlandığını denetler. Parametreler createUiDefinition.json ile ana şablon arasında ada göre eşlendiğinden adlar eşleşmelidir.
Bu test ana şablonu ve createUiDefinition.json dosyasını denetler. Ana şablon örneklerinden sonra createUiDefinition.json dosyasının bir örneği gösterilir.
Ana şablon createUiDefinition.json dosyasının outputs
bölümündeki parametreyi comboBox
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')]"
}
}
}
Ana şablon parametresini comboBox
içerdiğinden aşağıdaki örnek 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 örnek iç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()]"
}
}
}
Varsayılan olmayan parametreler çıkışlarda bulunmalıdır
Test adı: Varsayılan Olmayan Parametreler CreateUIDefinition Içinde Mevcut Olmalıdır
Ana şablondaki varsayılan değer içermeyen 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ının bir örneği gösterilir.
createUiDefinition.json dosyasının outputs
dosyasında ana şablonun parametresi comboBox
bulunmadığından 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": "This is a tool tip"
}
],
"steps": [],
"outputs": {
"location": "[location()]"
}
}
}
aşağıdaki örnek, createUiDefinition.json dosyasında outputs
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 yoktur.
{
"$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.jsonoutputs
dosyasının içinde tanımlandığını denetler. Bir parola kutusu için ana şablonun parametre türü veya secureObject
olmalıdırsecureString
.
Bu test ana şablonu ve createUiDefinition.json dosyasını denetler. Ana şablon örneklerinden sonra createUiDefinition.json dosyasının bir örneği gösterilir.
Ana şablonun passwordBox
parametresi bir string
olduğundan aşağıdaki örnek başarısız oluyor.
{
"$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')]"
}
}
}
Ana şablonun passwordBox
parametresi bir secureString
olduğundan aşağıdaki örnek 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 örnek iç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 minimum 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 kullandığını constraints
denetler.
Aşağıdaki örnek, olmadığından constraints
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": "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 message
içeren regex
onay kutularını denetlemek için constraints
metin kutularıyla doğrulamayı kullanın.
Aşağıdaki örnek baş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": "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 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": "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ı 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 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": "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 dosyasındaki herhangi bir validations
öğesinin bir içerdiğini message
denetler.
Doğrulamada regex
bir message
olmadığından aşağıdaki örnek baş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": "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 öğesinin createUiDefinition.jsonoutputs
dosyasında ve ana şablonun bölümünde olup olmadığını parameters
denetler. belirten defaultValue
ana şablon parametreleri denetimin allowedSizes
iç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 allowedSizes
bir değerle eşleşmediğinden 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"
},
"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 allowedSizes
bir 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 örnek iç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
- Azure portal kullanıcı arabirimi oluşturmak için bkz. Azure yönetilen uygulamasının oluşturma deneyimi için CreateUiDefinition.json.
- UI Tanımı Korumalı Alanı Oluşturma'yı kullanmak için bkz. Azure Yönetilen Uygulamaları için portal arabiriminizi test etme.
- Ui denetimleri hakkında daha fazla bilgi için bkz . CreateUiDefinition öğeleri ve CreateUiDefinition işlevleri.
- ARM şablon testleri hakkında daha fazla bilgi edinmek için bkz. ARM şablonları için test çalışmaları.