Þjálfun
Eining
Build reusable Bicep templates by using parameters - Training
Control and apply parameters to a Bicep template while protecting sensitive inputs.
Þessi vafri er ekki lengur studdur.
Uppfærðu í Microsoft Edge til að nýta þér nýjustu eiginleika, öryggisuppfærslur og tæknilega aðstoð.
This article describes the tests that are run with the template test toolkit for parameter files. For example, a file named azuredeploy.parameters.json. The examples include the test names and code samples that pass or fail the tests. For more information about how to run tests or how to run a specific test, see Test parameters.
The toolkit includes test cases for Azure Resource Manager templates (ARM templates) and the main template files named azuredeploy.json or maintemplate.json.
Test name: DeploymentParameters Should Have ContentVersion
The contentVersion
must contain a string in the format 1.0.0.0
and only use numbers.
The following example fails because the contentVersion
is missing.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"parameters": {
"stgAcctName": {
"value": "demostorage01"
}
}
}
The following example fails because contentVersion
isn't a string.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": {},
"parameters": {
"stgAcctName": {
"value": "demostorage01"
}
}
}
The following example passes.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"stgAcctName": {
"value": "demostorage01"
}
}
}
Test name: DeploymentParameters Should Have Parameters
A parameter file must include the parameters
section.
The following example fails.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
}
The following example passes.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"stgAcctName": {
"value": "demostorage01"
}
}
}
Test name: DeploymentParameters Should Have Schema
The parameter file must include a valid schema version.
There are two valid schema versions for parameter files:
https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#
https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#
The following example fails.
{
"$schema": "https://schema.management.azure.com/schemas/2021-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"stgAcctName": {
"value": "demostorage01"
}
}
}
The following example passes.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"stgAcctName": {
"value": "demostorage01"
}
}
}
Test name: DeploymentParameters Should Have Value
A parameter must contain a value
or a reference
. For secrets such as a password, a key vault uses a reference
in the parameter file. For more information, see Use Azure Key Vault to pass secure parameter value during deployment.
The following example fails because stgAcctName
doesn't have a value
.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"stgAcctName": {}
}
}
The following example passes.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"stgAcctName": {
"value": "demostorage01"
}
}
}
Þjálfun
Eining
Build reusable Bicep templates by using parameters - Training
Control and apply parameters to a Bicep template while protecting sensitive inputs.
Skjöl
Template test cases for test toolkit - Azure Resource Manager
Describes the template tests that are run by the Azure Resource Manager template test toolkit.
All files test cases for Azure Resource Manager test toolkit - Azure Resource Manager
Describes the tests that are run for all files by the Azure Resource Manager template test toolkit.
ARM template test toolkit - Azure Resource Manager
Describes how to run the Azure Resource Manager template (ARM template) test toolkit on your template. The toolkit lets you see if you have implemented recommended practices.