From b27a4430daf40d03d6bf9e7c431f02a6dd68fd53 Mon Sep 17 00:00:00 2001 From: John Aziz Date: Fri, 8 Mar 2024 02:00:54 +0200 Subject: [PATCH 01/12] Add cosmos mongo vcore cluster --- .../cosmos/mongo/cosmos-mongo-cluster.bicep | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep new file mode 100644 index 00000000000..70c1ba71d29 --- /dev/null +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -0,0 +1,73 @@ +@description('Azure Cosmos DB MongoDB vCore cluster name') +@maxLength(40) +param name string + +@description('Location for the cluster.') +param location string = resourceGroup().location + +param tags object = {} + +@description('Username for admin user') +param administratorLogin string + +@secure() +@description('Password for admin user') +@minLength(8) +@maxLength(128) +param administratorLoginPassword string + + +param sku string +param storage int +param nodeCount int +param highAvailabilityMode bool = false + +param allowAzureIPsFirewall bool = false +param allowAllIPsFirewall bool = false +param allowedSingleIPs array = [] + +resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { + name: name + tags: tags + location: location + properties: { + administratorLogin: administratorLogin + administratorLoginPassword: administratorLoginPassword + nodeGroupSpecs: [ + { + diskSizeGB: storage + enableHa: highAvailabilityMode + kind: 'Shard' + nodeCount: nodeCount + sku: sku + } + ] + } + + resource firewall_all 'firewallRules' = if (allowAllIPsFirewall) { + name: 'allow-all-IPs' + properties: { + startIpAddress: '0.0.0.0' + endIpAddress: '255.255.255.255' + } + } + + resource firewall_azure 'firewallRules' = if (allowAzureIPsFirewall) { + name: 'allow-all-azure-internal-IPs' + properties: { + startIpAddress: '0.0.0.0' + endIpAddress: '0.0.0.0' + } + } + + resource firewall_single 'firewallRules' = [for ip in allowedSingleIPs: { + name: 'allow-single-${replace(ip, '.', '')}' + properties: { + startIpAddress: ip + endIpAddress: ip + } + }] + +} + +output connectionStringKey string = mognoCluster.properties.connectionString From 03e5b1036b4672675de6d6224591de006c15f40a Mon Sep 17 00:00:00 2001 From: John Aziz Date: Fri, 8 Mar 2024 02:03:22 +0200 Subject: [PATCH 02/12] Update cosmos-mongo-cluster.bicep --- .../cosmos/mongo/cosmos-mongo-cluster.bicep | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 70c1ba71d29..f87674c05f5 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -1,27 +1,16 @@ -@description('Azure Cosmos DB MongoDB vCore cluster name') +metadata description = 'Azure Cosmos DB MongoDB vCore cluster name' @maxLength(40) param name string - -@description('Location for the cluster.') param location string = resourceGroup().location - param tags object = {} -@description('Username for admin user') param administratorLogin string - -@secure() -@description('Password for admin user') -@minLength(8) -@maxLength(128) -param administratorLoginPassword string - - param sku string param storage int param nodeCount int +@secure() +param administratorLoginPassword string param highAvailabilityMode bool = false - param allowAzureIPsFirewall bool = false param allowAllIPsFirewall bool = false param allowedSingleIPs array = [] From 46af17a7436546f2b15f8e11f715a9eb4c455877 Mon Sep 17 00:00:00 2001 From: John Aziz Date: Fri, 8 Mar 2024 02:05:16 +0200 Subject: [PATCH 03/12] Update cosmos-mongo-cluster.bicep --- .../bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index f87674c05f5..12f0ee80721 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -1,4 +1,4 @@ -metadata description = 'Azure Cosmos DB MongoDB vCore cluster name' +metadata description = 'Azure Cosmos DB MongoDB vCore cluster' @maxLength(40) param name string param location string = resourceGroup().location From f74d5ff3893b9d00141b125d871b5f90e49d9c6a Mon Sep 17 00:00:00 2001 From: John Aziz Date: Sat, 9 Mar 2024 00:26:47 +0200 Subject: [PATCH 04/12] alpha sort params --- .../database/cosmos/mongo/cosmos-mongo-cluster.bicep | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 12f0ee80721..4cfd0b204e6 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -5,15 +5,16 @@ param location string = resourceGroup().location param tags object = {} param administratorLogin string -param sku string -param storage int -param nodeCount int @secure() param administratorLoginPassword string -param highAvailabilityMode bool = false -param allowAzureIPsFirewall bool = false param allowAllIPsFirewall bool = false +param allowAzureIPsFirewall bool = false param allowedSingleIPs array = [] +param highAvailabilityMode bool = false +param nodeCount int +param sku string +param storage int + resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { name: name From 9d622b0c521885bd5db130cd77832acf9bd0714a Mon Sep 17 00:00:00 2001 From: John Aziz Date: Sat, 9 Mar 2024 00:27:10 +0200 Subject: [PATCH 05/12] Update cosmos-mongo-cluster.bicep --- .../bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 4cfd0b204e6..dc2c02e9832 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -15,7 +15,6 @@ param nodeCount int param sku string param storage int - resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { name: name tags: tags From 95b5472c68e439b0b4863ee06869b03aa5ba9fc4 Mon Sep 17 00:00:00 2001 From: John Aziz Date: Mon, 11 Mar 2024 21:54:24 +0200 Subject: [PATCH 06/12] add node type param --- .../bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index dc2c02e9832..6ab1e1d5a8d 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -12,6 +12,7 @@ param allowAzureIPsFirewall bool = false param allowedSingleIPs array = [] param highAvailabilityMode bool = false param nodeCount int +param nodeType string = 'Shard' param sku string param storage int From 33ebd756065a3b19cd99352724632d5100250125 Mon Sep 17 00:00:00 2001 From: John Aziz Date: Mon, 11 Mar 2024 23:38:15 +0200 Subject: [PATCH 07/12] add description --- .../cosmos/mongo/cosmos-mongo-cluster.bicep | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 6ab1e1d5a8d..19bb2050572 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -4,16 +4,30 @@ param name string param location string = resourceGroup().location param tags object = {} +@description('Username for admin user') param administratorLogin string @secure() +@description('Password for admin user') +@minLength(8) +@maxLength(128) param administratorLoginPassword string +@description('Whether to allow all IPs or not. Warning: No IP addresses will be blocked and any host on the Internet can access the coordinator in this server group. It is strongly recommended to use this rule only temporarily and only on test clusters that do not contain sensitive data.') param allowAllIPsFirewall bool = false +@description('Whether to allow Azure internal IPs or not.') param allowAzureIPsFirewall bool = false +@description('IPs address to allow access to the cluster from.') param allowedSingleIPs array = [] +@description('Mode to create the mongo cluster') +param createMode string = 'Default' +@description('Whether high availability is enabled on the node group') param highAvailabilityMode bool = false +@description('Number of nodes in the node group') param nodeCount int +@description('Node type deployed in the node group') param nodeType string = 'Shard' +@description('SKU defines the CPU and memory that is provisioned for each node') param sku string +@description('Disk storage size for the node group in GB') param storage int resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { @@ -23,6 +37,7 @@ resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = properties: { administratorLogin: administratorLogin administratorLoginPassword: administratorLoginPassword + createMode: createMode nodeGroupSpecs: [ { diskSizeGB: storage From ae0012287a76c2a5897cadc34cd4d87d0b4fc085 Mon Sep 17 00:00:00 2001 From: John Aziz Date: Mon, 11 Mar 2024 23:40:49 +0200 Subject: [PATCH 08/12] Update cosmos-mongo-cluster.bicep --- .../bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 19bb2050572..492bde0ba1d 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -15,7 +15,7 @@ param administratorLoginPassword string param allowAllIPsFirewall bool = false @description('Whether to allow Azure internal IPs or not.') param allowAzureIPsFirewall bool = false -@description('IPs address to allow access to the cluster from.') +@description('IPs addresses to allow access to the cluster from') param allowedSingleIPs array = [] @description('Mode to create the mongo cluster') param createMode string = 'Default' From a6a28f60e4fe8124c0533f72ae5bd24bc93513be Mon Sep 17 00:00:00 2001 From: John Aziz Date: Mon, 11 Mar 2024 23:41:17 +0200 Subject: [PATCH 09/12] Update cosmos-mongo-cluster.bicep --- .../bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 492bde0ba1d..01e336789a8 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -15,7 +15,7 @@ param administratorLoginPassword string param allowAllIPsFirewall bool = false @description('Whether to allow Azure internal IPs or not.') param allowAzureIPsFirewall bool = false -@description('IPs addresses to allow access to the cluster from') +@description('IP addresses to allow access to the cluster from') param allowedSingleIPs array = [] @description('Mode to create the mongo cluster') param createMode string = 'Default' From b75b0349139d144f5041c4eff49aba1520edfc6c Mon Sep 17 00:00:00 2001 From: John Aziz Date: Mon, 11 Mar 2024 23:42:37 +0200 Subject: [PATCH 10/12] Update cosmos-mongo-cluster.bicep --- .../bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 01e336789a8..a8b50e0f7da 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -13,7 +13,7 @@ param administratorLogin string param administratorLoginPassword string @description('Whether to allow all IPs or not. Warning: No IP addresses will be blocked and any host on the Internet can access the coordinator in this server group. It is strongly recommended to use this rule only temporarily and only on test clusters that do not contain sensitive data.') param allowAllIPsFirewall bool = false -@description('Whether to allow Azure internal IPs or not.') +@description('Whether to allow Azure internal IPs or not') param allowAzureIPsFirewall bool = false @description('IP addresses to allow access to the cluster from') param allowedSingleIPs array = [] From 447e8f759271bc38948f7c1209c169d799fe4803 Mon Sep 17 00:00:00 2001 From: John Aziz Date: Mon, 11 Mar 2024 23:43:56 +0200 Subject: [PATCH 11/12] Update cosmos-mongo-cluster.bicep --- .../bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index a8b50e0f7da..252efa6212a 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -23,7 +23,7 @@ param createMode string = 'Default' param highAvailabilityMode bool = false @description('Number of nodes in the node group') param nodeCount int -@description('Node type deployed in the node group') +@description('Deployed Node type in the node group') param nodeType string = 'Shard' @description('SKU defines the CPU and memory that is provisioned for each node') param sku string From a4ccda72bb665e89c7beb1c46f52daadfbdc739f Mon Sep 17 00:00:00 2001 From: John Aziz Date: Fri, 19 Jul 2024 17:57:42 +0300 Subject: [PATCH 12/12] update to the latest version --- .../core/database/cosmos/mongo/cosmos-mongo-cluster.bicep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep index 252efa6212a..7d6f110e14a 100644 --- a/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep +++ b/templates/common/infra/bicep/core/database/cosmos/mongo/cosmos-mongo-cluster.bicep @@ -30,7 +30,7 @@ param sku string @description('Disk storage size for the node group in GB') param storage int -resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { +resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2024-02-15-preview' = { name: name tags: tags location: location @@ -42,7 +42,7 @@ resource mognoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { diskSizeGB: storage enableHa: highAvailabilityMode - kind: 'Shard' + kind: nodeType nodeCount: nodeCount sku: sku }