It will generate automation payload!
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"administratorLogin": {
"type": "string"
},
"administratorLoginPassword": {
"type": "securestring"
},
"location": {
"type": "string"
},
"serverName": {
"type": "string"
},
"serverEdition": {
"type": "string"
},
"storageSizeGB": {
"type": "int"
},
"haEnabled": {
"type": "string",
"defaultValue": "Disabled"
},
"availabilityZone": {
"type": "string",
"defaultValue": ""
},
"standbyAvailabilityZone": {
"type": "string",
"defaultValue": ""
},
"version": {
"type": "string"
},
"tags": {
"type": "object",
"defaultValue": {}
},
"firewallRules": {
"type": "object",
"defaultValue": {}
},
"storageAutogrow": {
"type": "string",
"defaultValue": "Disabled"
},
"backupRetentionDays": {
"type": "int"
},
"geoRedundantBackup": {
"type": "string"
},
"vmName": {
"type": "string",
"defaultValue": "Standard_D4s_v3"
},
"identityData": {
"type": "object",
"defaultValue": {}
},
"dataEncryptionData": {
"type": "object",
"defaultValue": {}
},
"apiVersion": {
"type": "string",
"defaultValue": "2022-12-01"
},
"aadEnabled": {
"type": "bool",
"defaultValue": false
},
"aadData": {
"type": "object",
"defaultValue": {}
},
"authConfig": {
"type": "object",
"defaultValue": {}
},
"network": {
"type": "object",
"defaultValue": {}
},
"iopsTier": {
"type": "string",
"defaultValue": ""
},
"storageIops": {
"type": "int",
"defaultValue": 0
},
"throughput": {
"type": "int",
"defaultValue": 0
},
"storageType": {
"type": "string",
"defaultValue": ""
},
"guid": {
"type": "string",
"defaultValue": "[newGuid()]"
}
},
"variables": {
"firewallRules": "[parameters('firewallRules').rules]"
},
"resources": [
{
"apiVersion": "[parameters('apiVersion')]",
"location": "[parameters('location')]",
"name": "[parameters('serverName')]",
"identity": "[if(empty(parameters('identityData')), json('null'), parameters('identityData'))]",
"properties": {
"createMode": "Default",
"version": "[parameters('version')]",
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"Network": "[if(empty(parameters('network')), json('null'), parameters('network'))]",
"availabilityZone": "[parameters('availabilityZone')]",
"Storage": {
"StorageSizeGB": "[parameters('storageSizeGB')]",
"Type": "[if(empty(parameters('storageType')), json('null'),parameters('storageType'))]",
"Autogrow": "[parameters('storageAutogrow')]",
"tier": "[if(empty(parameters('iopsTier')), json('null'), parameters('iopsTier'))]",
"Iops": "[if(equals(parameters('storageIops'), 0), json('null'), parameters('storageIops'))]",
"Throughput": "[if(equals(parameters('throughput'), 0), json('null'), parameters('throughput'))]"
},
"Backup": {
"backupRetentionDays": "[parameters('backupRetentionDays')]",
"geoRedundantBackup": "[parameters('geoRedundantBackup')]"
},
"highAvailability": {
"mode": "[parameters('haEnabled')]",
"standbyAvailabilityZone": "[parameters('standbyAvailabilityZone')]"
},
"dataencryption": "[if(empty(parameters('dataEncryptionData')), json('null'), parameters('dataEncryptionData'))]",
"authConfig": "[if(empty(parameters('authConfig')), json('null'), parameters('authConfig'))]"
},
"sku": {
"name": "[parameters('vmName')]",
"tier": "[parameters('serverEdition')]"
},
"tags": "[parameters('tags')]",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
},
{
"condition": "[parameters('aadEnabled')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "[concat('addAdmins-', parameters('guid'))]",
"dependsOn": [
"[concat('Microsoft.DBforPostgreSQL/flexibleServers/', parameters('serverName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.DBforPostgreSQL/flexibleServers/administrators",
"name": "[concat(parameters('serverName'),'/', parameters('aadData').objectId)]",
"apiVersion": "[parameters('apiVersion')]",
"properties": {
"tenantId": "[parameters('aadData').tenantId]",
"principalName": "[parameters('aadData').principalName]",
"principalType": "[parameters('aadData').principalType]"
}
}
]
}
}
},
{
"condition": "[greater(length(variables('firewallRules')), 0)]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2019-08-01",
"name": "[concat('firewallRules-', parameters('guid'), '-', copyIndex())]",
"copy": {
"count": "[if(greater(length(variables('firewallRules')), 0), length(variables('firewallRules')), 1)]",
"mode": "Serial",
"name": "firewallRulesIterator"
},
"dependsOn": [
"[concat('Microsoft.DBforPostgreSQL/flexibleServers/', parameters('serverName'))]",
"[concat('Microsoft.Resources/deployments/addAdmins-', parameters('guid'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules",
"name": "[concat(parameters('serverName'),'/',variables('firewallRules')[copyIndex()].name)]",
"apiVersion": "[parameters('apiVersion')]",
"properties": {
"StartIpAddress": "[variables('firewallRules')[copyIndex()].startIPAddress]",
"EndIpAddress": "[variables('firewallRules')[copyIndex()].endIPAddress]"
}
}
]
}
}
}
]
}
export PGHOST=dave-database.postgres.database.azure.com
export PGUSER=ansible
export PGPORT=5432
export PGDATABASE=aap
export PGPASSWORD="{your-password}"
apiVersion: v1
kind: Secret
metadata:
name: external-postgres-configuration
namespace: aap
stringData:
database: "aap"
host: "dave-database.postgres.database.azure.com"
password: "{your-password}"
port: "5432"
sslmode: "allow"
type: "unmanaged"
username: "ansible"
type: Opaque
Becomes when applied:
kind: Secret
apiVersion: v1
metadata:
name: external-postgres-configuration
namespace: aap
data:
database: cG9zdGdyZXM=
host: ZGF2ZS1kYXRhYmFzZS5wb3N0Z3Jlcy5kYXRhYmFzZS5henVyZS5jb20=
password: your-password-hash
port: NTQzMg==
sslmode: YWxsb3c=
type: dW5tYW5hZ2Vk
username: YW5zaWJsZQ==
type: Opaque