MySQL 和 Postgresql 的 Azure 数据库的一个 ARM 模板?
One ARM-template for Azure database for MySQL and Postgresql?
我目前正在尝试编写一个 ARM 模板,它应该在 deploy.json 文件中包含 MySQL 和 PostgreSQL,然后有两个单独的参数文件,一个用于 postgreSQL,一个用于 [=23] =].
我已经开始使用模板,但它也无法按照我想要的方式工作,我也不知道为什么。在模板中我有 Microsoft.DBforMySQL/servers 和 Microsoft.DBforPostgreSQL/servers.
"resources": [
{
"type": "Microsoft.DBforMySQL/servers",
"apiVersion": "2017-12-01",
"name":
"location":
"sku": {
"name":
},
"properties": {
"version":
"administratorLogin":
"administratorLoginPassword":
"createMode":
"sslEnforcement":
"storageProfile": {
"storageGb":
"backupRetentionDays":
"geoRedundantBackup":
}
}
},
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"name":
"location":
"sku": {
"name":
},
"properties": {
"apiVersion":
"administratorLogin":
"administratorLoginPassword":
"createMode":
"sslEnforcement":
"storageProfile": {
"storageGb":
"backupRetentionDays":
"geoRedundantBackup":
}
},
我想要实现的输出是,当您使用例如 "Postgre-parameter" 文件时,它应该部署一个 PostgreSQL 数据库并读取资源 "Microsoft.DBforPostgreSQL/servers",反之亦然。这是可能的还是我应该停止尝试?
这是可能的,但不是神奇的(你似乎认为它应该这样做)。你必须为它编码。最简单的方法是向资源添加条件:
"resources": [
{
"condition": "[equals(parameters('postgres'), true)]"
...
},
{
"condition": "[equals(parameters('mysql'), true)]"
...
},
]
您还必须将参数值映射到资源。
语法:https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authoring-templates
我目前正在尝试编写一个 ARM 模板,它应该在 deploy.json 文件中包含 MySQL 和 PostgreSQL,然后有两个单独的参数文件,一个用于 postgreSQL,一个用于 [=23] =].
我已经开始使用模板,但它也无法按照我想要的方式工作,我也不知道为什么。在模板中我有 Microsoft.DBforMySQL/servers 和 Microsoft.DBforPostgreSQL/servers.
"resources": [
{
"type": "Microsoft.DBforMySQL/servers",
"apiVersion": "2017-12-01",
"name":
"location":
"sku": {
"name":
},
"properties": {
"version":
"administratorLogin":
"administratorLoginPassword":
"createMode":
"sslEnforcement":
"storageProfile": {
"storageGb":
"backupRetentionDays":
"geoRedundantBackup":
}
}
},
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"name":
"location":
"sku": {
"name":
},
"properties": {
"apiVersion":
"administratorLogin":
"administratorLoginPassword":
"createMode":
"sslEnforcement":
"storageProfile": {
"storageGb":
"backupRetentionDays":
"geoRedundantBackup":
}
},
我想要实现的输出是,当您使用例如 "Postgre-parameter" 文件时,它应该部署一个 PostgreSQL 数据库并读取资源 "Microsoft.DBforPostgreSQL/servers",反之亦然。这是可能的还是我应该停止尝试?
这是可能的,但不是神奇的(你似乎认为它应该这样做)。你必须为它编码。最简单的方法是向资源添加条件:
"resources": [
{
"condition": "[equals(parameters('postgres'), true)]"
...
},
{
"condition": "[equals(parameters('mysql'), true)]"
...
},
]
您还必须将参数值映射到资源。
语法:https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authoring-templates