我按照https://github.com/Azure/bicep/discussions/4586中定义的每个env的单独参数文件的repo
我尝试为dev、stage、prod使用单独的参数文件,但是主模块变量中的赋值仍然被智能标记,即使它在相应的参数文件中存在相同的参数。
我尝试的另一种方法是loadjson变量,但是它不会自动完成子网块下的项,因为它在value之后停止。
也许我想得太多了,没有应用正确的方法,也许我应该忽略智能感知,尝试通过应用参数进行部署,并希望它在部署参数检查期间自动选择正确的值。
下面是我的参数文件,相同的值适用于每个env param json。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"department": {
"value": "finance"
},
"saAccountCount": {
"value": 1
},
"vmCount": {
"value": 1
},
"locationIndex": { //idenx 1 = app server, 2=AD, 3=Tool server, 4= dchp server
"value": 1
},
"appRoleIndex": { //idenx 1 = westus2, 2= westus, 3= eastus, 4=centralus, 5=uswest3
"value": 1
},
"appRole": {
"value": {
"Applicatoin Server": "ap",
"Active Directory": "dc",
"Tool server": "tool",
"DHCP server": "dhcp"
}
},
"environment": {
"value": "dev"
},
"addressPrefixes": {
"value": [
"172.16.0.0/20"
]
},
"dnsServers": {
"value": [
"1.1.1.1",
"4.4.4.4"
]
},
"locationList": {
"value": {
"westus2": "azw2",
"westus": "azw",
"Eastus": "aze",
"CentralUS": "azc",
"westus3": "azw3"
}
},
"subnets": {
"value": [
{
"name": "frontend",
"subnetPrefix": "172.16.2.0/24",
"delegation": "Microsoft.Web/serverfarms",
"privateEndpointNetworkPolicies": "disabled",
"serviceEndpoints": [
{
"service": "Microsoft.KeyVault",
"locations": [
"*"
]
},
{
"service": "Microsoft.Web",
"locations": [
"*"
]
}
]
},
{
"name": "backend",
"subnetPrefix": "172.16.3.0/24",
"delegation": "Microsoft.Web/serverfarms",
"privateEndpointNetworkPolicies": "enabled",
"serviceEndpoints": [
{
"service": "Microsoft.KeyVault",
"locations": [
"*"
]
},
{
"service": "Microsoft.Web",
"locations": [
"*"
]
},
{
"service": "Microsoft.AzureCosmosDB",
"locations": [
"*"
]
}
]
}
]
}
}
}
1条答案
按热度按时间qvtsj1bj1#
如果参数文件包含与ARM模板参数不匹配的额外参数,您将收到错误。
Refer to create a parameter file of an ARM template
关于
dev, stage, and prod
的不同参数文件,可能是参数文件未正确链接到ARM模板。您可以仔细检查loadjson变量的格式以确保其正确。
在解决了这个问题之后,我创建了一个示例
parameter.json
文件,用于在production
环境中部署webapp,这对我很有效。**注意:**或者,您可以将az deployment group create与参数文件一起使用并部署到Azure中,以避免这些冲突。