diff --git a/avm/res/kusto/cluster/README.md b/avm/res/kusto/cluster/README.md index 05cc3e5dfd..83b98f070f 100644 --- a/avm/res/kusto/cluster/README.md +++ b/avm/res/kusto/cluster/README.md @@ -18,7 +18,8 @@ This module deploys a Kusto Cluster. | `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) | | `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) | | `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) | -| `Microsoft.Kusto/clusters` | [2023-08-15](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Kusto/2023-08-15/clusters) | +| `Microsoft.Kusto/clusters` | [2024-04-13](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Kusto/2024-04-13/clusters) | +| `Microsoft.Kusto/clusters/databases` | [2024-04-13](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Kusto/2024-04-13/clusters/databases) | | `Microsoft.Kusto/clusters/principalAssignments` | [2023-08-15](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Kusto/2023-08-15/clusters/principalAssignments) | | `Microsoft.Network/privateEndpoints` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/privateEndpoints) | | `Microsoft.Network/privateEndpoints/privateDnsZoneGroups` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/privateEndpoints/privateDnsZoneGroups) | @@ -55,7 +56,13 @@ module cluster 'br/public:avm/res/kusto/cluster:' = { name: 'kcmin0001' sku: 'Standard_E2ads_v5' // Non-required parameters + enableDiskEncryption: true location: '' + managedIdentities: { + userAssignedResourceIds: [ + '' + ] + } } } ``` @@ -80,8 +87,18 @@ module cluster 'br/public:avm/res/kusto/cluster:' = { "value": "Standard_E2ads_v5" }, // Non-required parameters + "enableDiskEncryption": { + "value": true + }, "location": { "value": "" + }, + "managedIdentities": { + "value": { + "userAssignedResourceIds": [ + "" + ] + } } } } @@ -101,7 +118,13 @@ using 'br/public:avm/res/kusto/cluster:' param name = 'kcmin0001' param sku = 'Standard_E2ads_v5' // Non-required parameters +param enableDiskEncryption = true param location = '' +param managedIdentities = { + userAssignedResourceIds: [ + '' + ] +} ``` @@ -138,6 +161,16 @@ module cluster 'br/public:avm/res/kusto/cluster:' = { autoScaleMax: 6 autoScaleMin: 3 capacity: 3 + databases: [ + { + kind: 'ReadWrite' + name: 'myReadWriteDatabase' + readWriteProperties: { + hotCachePeriod: 'P1D' + softDeletePeriod: 'P7D' + } + } + ] enableAutoScale: true enableAutoStop: true enableDiskEncryption: true @@ -235,6 +268,18 @@ module cluster 'br/public:avm/res/kusto/cluster:' = { "capacity": { "value": 3 }, + "databases": { + "value": [ + { + "kind": "ReadWrite", + "name": "myReadWriteDatabase", + "readWriteProperties": { + "hotCachePeriod": "P1D", + "softDeletePeriod": "P7D" + } + } + ] + }, "enableAutoScale": { "value": true }, @@ -346,6 +391,16 @@ param allowedIpRangeList = [ param autoScaleMax = 6 param autoScaleMin = 3 param capacity = 3 +param databases = [ + { + kind: 'ReadWrite' + name: 'myReadWriteDatabase' + readWriteProperties: { + hotCachePeriod: 'P1D' + softDeletePeriod: 'P7D' + } + } +] param enableAutoScale = true param enableAutoStop = true param enableDiskEncryption = true @@ -925,6 +980,7 @@ param tier = 'Standard' | [`autoScaleMin`](#parameter-autoscalemin) | int | When auto-scale is enabled, the minimum number of instances in the Kusto Cluster. | | [`capacity`](#parameter-capacity) | int | The number of instances of the Kusto Cluster. | | [`customerManagedKey`](#parameter-customermanagedkey) | object | The customer managed key definition. | +| [`databases`](#parameter-databases) | array | The Kusto Cluster databases. | | [`diagnosticSettings`](#parameter-diagnosticsettings) | array | The diagnostic settings of the service. | | [`enableAutoScale`](#parameter-enableautoscale) | bool | Enable/disable auto-scale. | | [`enableAutoStop`](#parameter-enableautostop) | bool | Enable/disable auto-stop. | @@ -1091,6 +1147,142 @@ User assigned identity to use when fetching the customer managed key. Required i - MinValue: 2 - MaxValue: 999 +### Parameter: `databases` + +The Kusto Cluster databases. + +- Required: No +- Type: array +- MinValue: 2 +- MaxValue: 999 + +**Required parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`kind`](#parameter-databaseskind) | string | The object type of the databse. | +| [`name`](#parameter-databasesname) | string | The name of the Kusto Cluster database. | + +**Conditional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`readWriteProperties`](#parameter-databasesreadwriteproperties) | object | Required if the database kind is ReadWrite. Contains the properties of the database. | + +### Parameter: `databases.kind` + +The object type of the databse. + +- Required: Yes +- Type: string +- Allowed: + ```Bicep + [ + 'ReadOnlyFollowing' + 'ReadWrite' + ] + ``` +- MinValue: 2 +- MaxValue: 999 + +### Parameter: `databases.name` + +The name of the Kusto Cluster database. + +- Required: Yes +- Type: string +- MinValue: 2 +- MaxValue: 999 + +### Parameter: `databases.readWriteProperties` + +Required if the database kind is ReadWrite. Contains the properties of the database. + +- Required: No +- Type: object +- MinValue: 2 +- MaxValue: 999 + +**Optional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`hotCachePeriod`](#parameter-databasesreadwritepropertieshotcacheperiod) | string | Te time the data should be kept in cache for fast queries in TimeSpan. | +| [`keyVaultProperties`](#parameter-databasesreadwritepropertieskeyvaultproperties) | object | The properties of the key vault. | +| [`softDeletePeriod`](#parameter-databasesreadwritepropertiessoftdeleteperiod) | string | The time the data should be kept before it stops being accessible to queries in TimeSpan. | + +### Parameter: `databases.readWriteProperties.hotCachePeriod` + +Te time the data should be kept in cache for fast queries in TimeSpan. + +- Required: No +- Type: string +- MinValue: 2 +- MaxValue: 999 + +### Parameter: `databases.readWriteProperties.keyVaultProperties` + +The properties of the key vault. + +- Required: No +- Type: object +- MinValue: 2 +- MaxValue: 999 + +**Optional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`keyName`](#parameter-databasesreadwritepropertieskeyvaultpropertieskeyname) | string | The name of the key. | +| [`keyVaultUri`](#parameter-databasesreadwritepropertieskeyvaultpropertieskeyvaulturi) | string | The Uri of the key vault. | +| [`keyVersion`](#parameter-databasesreadwritepropertieskeyvaultpropertieskeyversion) | string | The version of the key. | +| [`userIdentity`](#parameter-databasesreadwritepropertieskeyvaultpropertiesuseridentity) | string | The user identity. | + +### Parameter: `databases.readWriteProperties.keyVaultProperties.keyName` + +The name of the key. + +- Required: No +- Type: string +- MinValue: 2 +- MaxValue: 999 + +### Parameter: `databases.readWriteProperties.keyVaultProperties.keyVaultUri` + +The Uri of the key vault. + +- Required: No +- Type: string +- MinValue: 2 +- MaxValue: 999 + +### Parameter: `databases.readWriteProperties.keyVaultProperties.keyVersion` + +The version of the key. + +- Required: No +- Type: string +- MinValue: 2 +- MaxValue: 999 + +### Parameter: `databases.readWriteProperties.keyVaultProperties.userIdentity` + +The user identity. + +- Required: No +- Type: string +- MinValue: 2 +- MaxValue: 999 + +### Parameter: `databases.readWriteProperties.softDeletePeriod` + +The time the data should be kept before it stops being accessible to queries in TimeSpan. + +- Required: No +- Type: string +- MinValue: 2 +- MaxValue: 999 + ### Parameter: `diagnosticSettings` The diagnostic settings of the service. @@ -2340,6 +2532,7 @@ The resource ID of the subnet to which to deploy the Kusto Cluster. | Output | Type | Description | | :-- | :-- | :-- | +| `databases` | array | The databases of the kusto cluster. | | `location` | string | The location the resource was deployed into. | | `name` | string | The name of the kusto cluster. | | `privateEndpoints` | array | The private endpoints of the kusto cluster. | diff --git a/avm/res/kusto/cluster/database/README.md b/avm/res/kusto/cluster/database/README.md new file mode 100644 index 0000000000..e2a7cb6284 --- /dev/null +++ b/avm/res/kusto/cluster/database/README.md @@ -0,0 +1,155 @@ +# Kusto Cluster Databases `[Microsoft.Kusto/clusters/databases]` + +This module deploys a Kusto Cluster Database. + +## Navigation + +- [Resource Types](#Resource-Types) +- [Parameters](#Parameters) +- [Outputs](#Outputs) + +## Resource Types + +| Resource Type | API Version | +| :-- | :-- | +| `Microsoft.Kusto/clusters/databases` | [2024-04-13](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Kusto/2024-04-13/clusters/databases) | + +## Parameters + +**Required parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`name`](#parameter-name) | string | The name of the Kusto Cluster database. | + +**Conditional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`kustoClusterName`](#parameter-kustoclustername) | string | The name of the parent Kusto Cluster. Required if the template is used in a standalone deployment. | + +**Optional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`databaseKind`](#parameter-databasekind) | string | The object type of the databse. | +| [`databaseReadWriteProperties`](#parameter-databasereadwriteproperties) | object | The properties of the database if using read-write. Only used if databaseKind is ReadWrite. | +| [`location`](#parameter-location) | string | Location for the databases. | + +### Parameter: `name` + +The name of the Kusto Cluster database. + +- Required: Yes +- Type: string + +### Parameter: `kustoClusterName` + +The name of the parent Kusto Cluster. Required if the template is used in a standalone deployment. + +- Required: Yes +- Type: string + +### Parameter: `databaseKind` + +The object type of the databse. + +- Required: No +- Type: string +- Default: `'ReadWrite'` +- Allowed: + ```Bicep + [ + 'ReadOnlyFollowing' + 'ReadWrite' + ] + ``` + +### Parameter: `databaseReadWriteProperties` + +The properties of the database if using read-write. Only used if databaseKind is ReadWrite. + +- Required: No +- Type: object + +**Optional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`hotCachePeriod`](#parameter-databasereadwritepropertieshotcacheperiod) | string | Te time the data should be kept in cache for fast queries in TimeSpan. | +| [`keyVaultProperties`](#parameter-databasereadwritepropertieskeyvaultproperties) | object | The properties of the key vault. | +| [`softDeletePeriod`](#parameter-databasereadwritepropertiessoftdeleteperiod) | string | The time the data should be kept before it stops being accessible to queries in TimeSpan. | + +### Parameter: `databaseReadWriteProperties.hotCachePeriod` + +Te time the data should be kept in cache for fast queries in TimeSpan. + +- Required: No +- Type: string + +### Parameter: `databaseReadWriteProperties.keyVaultProperties` + +The properties of the key vault. + +- Required: No +- Type: object + +**Optional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`keyName`](#parameter-databasereadwritepropertieskeyvaultpropertieskeyname) | string | The name of the key. | +| [`keyVaultUri`](#parameter-databasereadwritepropertieskeyvaultpropertieskeyvaulturi) | string | The Uri of the key vault. | +| [`keyVersion`](#parameter-databasereadwritepropertieskeyvaultpropertieskeyversion) | string | The version of the key. | +| [`userIdentity`](#parameter-databasereadwritepropertieskeyvaultpropertiesuseridentity) | string | The user identity. | + +### Parameter: `databaseReadWriteProperties.keyVaultProperties.keyName` + +The name of the key. + +- Required: No +- Type: string + +### Parameter: `databaseReadWriteProperties.keyVaultProperties.keyVaultUri` + +The Uri of the key vault. + +- Required: No +- Type: string + +### Parameter: `databaseReadWriteProperties.keyVaultProperties.keyVersion` + +The version of the key. + +- Required: No +- Type: string + +### Parameter: `databaseReadWriteProperties.keyVaultProperties.userIdentity` + +The user identity. + +- Required: No +- Type: string + +### Parameter: `databaseReadWriteProperties.softDeletePeriod` + +The time the data should be kept before it stops being accessible to queries in TimeSpan. + +- Required: No +- Type: string + +### Parameter: `location` + +Location for the databases. + +- Required: No +- Type: string +- Default: `[resourceGroup().location]` + +## Outputs + +| Output | Type | Description | +| :-- | :-- | :-- | +| `name` | string | The name of the Kusto Cluster database. | +| `resourceGroupName` | string | The resource group containing the Kusto Cluster database. | +| `resourceId` | string | The resource ID of the Kusto Cluster database. | diff --git a/avm/res/kusto/cluster/database/main.bicep b/avm/res/kusto/cluster/database/main.bicep new file mode 100644 index 0000000000..695e6706c0 --- /dev/null +++ b/avm/res/kusto/cluster/database/main.bicep @@ -0,0 +1,78 @@ +metadata name = 'Kusto Cluster Databases' +metadata description = 'This module deploys a Kusto Cluster Database.' +metadata owner = 'Azure/module-maintainers' + +@description('Required. The name of the Kusto Cluster database.') +param name string + +@description('Conditional. The name of the parent Kusto Cluster. Required if the template is used in a standalone deployment.') +param kustoClusterName string + +@description('Optional. Location for the databases.') +param location string = resourceGroup().location + +@description('Optional. The object type of the databse.') +@allowed([ + 'ReadWrite' + 'ReadOnlyFollowing' +]) +param databaseKind string = 'ReadWrite' + +@description('Optional. The properties of the database if using read-write. Only used if databaseKind is ReadWrite.') +param databaseReadWriteProperties databaseReadWriteType + +resource kustoCluster 'Microsoft.Kusto/clusters@2024-04-13' existing = { + name: kustoClusterName +} + +resource database_readOnly 'Microsoft.Kusto/clusters/databases@2024-04-13' = if (databaseKind == 'ReadOnlyFollowing') { + name: name + parent: kustoCluster + location: location + kind: 'ReadOnlyFollowing' +} + +resource database_readWrite 'Microsoft.Kusto/clusters/databases@2024-04-13' = if (databaseKind == 'ReadWrite') { + name: name + parent: kustoCluster + location: location + kind: 'ReadWrite' + properties: databaseReadWriteProperties ?? null +} + +// =============== // +// Outputs // +// =============== // + +@description('The name of the Kusto Cluster database.') +output name string = databaseKind == 'ReadOnlyFollowing' ? database_readOnly.name : database_readWrite.name + +@description('The resource ID of the Kusto Cluster database.') +output resourceId string = databaseKind == 'ReadOnlyFollowing' ? database_readOnly.id : database_readWrite.id + +@description('The resource group containing the Kusto Cluster database.') +output resourceGroupName string = resourceGroup().name + +// =============== // +// Definitions // +// =============== // + +@export() +@description('Conditional. The properties of the database if using read-write.') +type databaseReadWriteType = { + @description('Optional. Te time the data should be kept in cache for fast queries in TimeSpan.') + hotCachePeriod: string? + @description('Optional. The properties of the key vault.') + keyVaultProperties: { + @description('Optional. The name of the key.') + keyName: string? + @description('Optional. The Uri of the key vault.') + keyVaultUri: string? + @description('Optional. The version of the key.') + keyVersion: string? + @description('Optional. The user identity.') + userIdentity: string? + }? + @description('Optional. The time the data should be kept before it stops being accessible to queries in TimeSpan.') + softDeletePeriod: string? +}? diff --git a/avm/res/kusto/cluster/database/main.json b/avm/res/kusto/cluster/database/main.json new file mode 100644 index 0000000000..3dda4691ba --- /dev/null +++ b/avm/res/kusto/cluster/database/main.json @@ -0,0 +1,164 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "languageVersion": "2.0", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.32.4.45862", + "templateHash": "18422341525898722212" + }, + "name": "Kusto Cluster Databases", + "description": "This module deploys a Kusto Cluster Database.", + "owner": "Azure/module-maintainers" + }, + "definitions": { + "databaseReadWriteType": { + "type": "object", + "properties": { + "hotCachePeriod": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. Te time the data should be kept in cache for fast queries in TimeSpan." + } + }, + "keyVaultProperties": { + "type": "object", + "properties": { + "keyName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The name of the key." + } + }, + "keyVaultUri": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The Uri of the key vault." + } + }, + "keyVersion": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The version of the key." + } + }, + "userIdentity": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The user identity." + } + } + }, + "nullable": true, + "metadata": { + "description": "Optional. The properties of the key vault." + } + }, + "softDeletePeriod": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The time the data should be kept before it stops being accessible to queries in TimeSpan." + } + } + }, + "nullable": true, + "metadata": { + "__bicep_export!": true, + "description": "Conditional. The properties of the database if using read-write." + } + } + }, + "parameters": { + "name": { + "type": "string", + "metadata": { + "description": "Required. The name of the Kusto Cluster database." + } + }, + "kustoClusterName": { + "type": "string", + "metadata": { + "description": "Conditional. The name of the parent Kusto Cluster. Required if the template is used in a standalone deployment." + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "Optional. Location for the databases." + } + }, + "databaseKind": { + "type": "string", + "defaultValue": "ReadWrite", + "allowedValues": [ + "ReadWrite", + "ReadOnlyFollowing" + ], + "metadata": { + "description": "Optional. The object type of the databse." + } + }, + "databaseReadWriteProperties": { + "$ref": "#/definitions/databaseReadWriteType", + "metadata": { + "description": "Optional. The properties of the database if using read-write. Only used if databaseKind is ReadWrite." + } + } + }, + "resources": { + "kustoCluster": { + "existing": true, + "type": "Microsoft.Kusto/clusters", + "apiVersion": "2024-04-13", + "name": "[parameters('kustoClusterName')]" + }, + "database_readOnly": { + "condition": "[equals(parameters('databaseKind'), 'ReadOnlyFollowing')]", + "type": "Microsoft.Kusto/clusters/databases", + "apiVersion": "2024-04-13", + "name": "[format('{0}/{1}', parameters('kustoClusterName'), parameters('name'))]", + "location": "[parameters('location')]", + "kind": "ReadOnlyFollowing" + }, + "database_readWrite": { + "condition": "[equals(parameters('databaseKind'), 'ReadWrite')]", + "type": "Microsoft.Kusto/clusters/databases", + "apiVersion": "2024-04-13", + "name": "[format('{0}/{1}', parameters('kustoClusterName'), parameters('name'))]", + "location": "[parameters('location')]", + "kind": "ReadWrite", + "properties": "[coalesce(parameters('databaseReadWriteProperties'), null())]" + } + }, + "outputs": { + "name": { + "type": "string", + "metadata": { + "description": "The name of the Kusto Cluster database." + }, + "value": "[if(equals(parameters('databaseKind'), 'ReadOnlyFollowing'), parameters('name'), parameters('name'))]" + }, + "resourceId": { + "type": "string", + "metadata": { + "description": "The resource ID of the Kusto Cluster database." + }, + "value": "[if(equals(parameters('databaseKind'), 'ReadOnlyFollowing'), resourceId('Microsoft.Kusto/clusters/databases', parameters('kustoClusterName'), parameters('name')), resourceId('Microsoft.Kusto/clusters/databases', parameters('kustoClusterName'), parameters('name')))]" + }, + "resourceGroupName": { + "type": "string", + "metadata": { + "description": "The resource group containing the Kusto Cluster database." + }, + "value": "[resourceGroup().name]" + } + } +} \ No newline at end of file diff --git a/avm/res/kusto/cluster/main.bicep b/avm/res/kusto/cluster/main.bicep index 9fc2c49254..2b1dfa226d 100644 --- a/avm/res/kusto/cluster/main.bicep +++ b/avm/res/kusto/cluster/main.bicep @@ -130,6 +130,9 @@ param diagnosticSettings diagnosticSettingFullType[]? @description('Optional. The Principal Assignments for the Kusto Cluster.') param principalAssignments principalAssignmentType[]? +@description('Optional. The Kusto Cluster databases.') +param databases databaseType[]? + // Converts the flat array to an object like { '${id1}': {}, '${id2}': {} } var formattedUserAssignedIdentities = reduce( map((managedIdentities.?userAssignedResourceIds ?? []), (id) => { '${id}': {} }), @@ -198,7 +201,7 @@ resource cMKKeyVault 'Microsoft.KeyVault/vaults@2023-07-01' existing = if (!empt } } -resource kustoCluster 'Microsoft.Kusto/clusters@2023-08-15' = { +resource kustoCluster 'Microsoft.Kusto/clusters@2024-04-13' = { name: name location: location tags: tags @@ -386,6 +389,18 @@ module kustoCluster_privateEndpoints 'br/public:avm/res/network/private-endpoint } ] +module kustoCluster_databases 'database/main.bicep' = [ + for (database, index) in (databases ?? []): { + name: '${uniqueString(deployment().name, location)}-kustoCluster-database-${index}' + params: { + name: database.name + kustoClusterName: kustoCluster.name + databaseKind: database.kind + databaseReadWriteProperties: database.kind == 'ReadWrite' ? database.readWriteProperties : null + } + } +] + // ============ // // Outputs // // ============ // @@ -416,6 +431,14 @@ output privateEndpoints array = [ } ] +@description('The databases of the kusto cluster.') +output databases array = [ + for (database, index) in (!empty(databases) ? array(databases) : []): { + name: kustoCluster_databases[index].outputs.name + resourceId: kustoCluster_databases[index].outputs.resourceId + } +] + // =============== // // Definitions // // =============== // @@ -470,3 +493,15 @@ type principalAssignmentType = { @description('Optional. The tenant id of the principal.') tenantId: string? } + +import { databaseReadWriteType } from './database/main.bicep' + +@export() +type databaseType = { + @description('Required. The name of the Kusto Cluster database.') + name: string + @description('Required. The object type of the databse.') + kind: 'ReadWrite' | 'ReadOnlyFollowing' + @description('Conditional. Required if the database kind is ReadWrite. Contains the properties of the database.') + readWriteProperties: databaseReadWriteType? +} diff --git a/avm/res/kusto/cluster/main.json b/avm/res/kusto/cluster/main.json index 2b30e761b4..0e4f6a08f1 100644 --- a/avm/res/kusto/cluster/main.json +++ b/avm/res/kusto/cluster/main.json @@ -6,7 +6,7 @@ "_generator": { "name": "bicep", "version": "0.32.4.45862", - "templateHash": "15367877000338557713" + "templateHash": "9035944392764193312" }, "name": "Kusto Cluster", "description": "This module deploys a Kusto Cluster.", @@ -146,6 +146,37 @@ "__bicep_export!": true } }, + "databaseType": { + "type": "object", + "properties": { + "name": { + "type": "string", + "metadata": { + "description": "Required. The name of the Kusto Cluster database." + } + }, + "kind": { + "type": "string", + "allowedValues": [ + "ReadOnlyFollowing", + "ReadWrite" + ], + "metadata": { + "description": "Required. The object type of the databse." + } + }, + "readWriteProperties": { + "$ref": "#/definitions/databaseReadWriteType", + "nullable": true, + "metadata": { + "description": "Conditional. Required if the database kind is ReadWrite. Contains the properties of the database." + } + } + }, + "metadata": { + "__bicep_export!": true + } + }, "_1.privateEndpointCustomDnsConfigType": { "type": "object", "properties": { @@ -292,6 +323,69 @@ } } }, + "databaseReadWriteType": { + "type": "object", + "properties": { + "hotCachePeriod": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. Te time the data should be kept in cache for fast queries in TimeSpan." + } + }, + "keyVaultProperties": { + "type": "object", + "properties": { + "keyName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The name of the key." + } + }, + "keyVaultUri": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The Uri of the key vault." + } + }, + "keyVersion": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The version of the key." + } + }, + "userIdentity": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The user identity." + } + } + }, + "nullable": true, + "metadata": { + "description": "Optional. The properties of the key vault." + } + }, + "softDeletePeriod": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The time the data should be kept before it stops being accessible to queries in TimeSpan." + } + } + }, + "nullable": true, + "metadata": { + "description": "Conditional. The properties of the database if using read-write.", + "__bicep_imported_from!": { + "sourceTemplate": "database/main.bicep" + } + } + }, "diagnosticSettingFullType": { "type": "object", "properties": { @@ -971,6 +1065,16 @@ "metadata": { "description": "Optional. The Principal Assignments for the Kusto Cluster." } + }, + "databases": { + "type": "array", + "items": { + "$ref": "#/definitions/databaseType" + }, + "nullable": true, + "metadata": { + "description": "Optional. The Kusto Cluster databases." + } } }, "variables": { @@ -1030,7 +1134,7 @@ }, "kustoCluster": { "type": "Microsoft.Kusto/clusters", - "apiVersion": "2023-08-15", + "apiVersion": "2024-04-13", "name": "[parameters('name')]", "location": "[parameters('location')]", "tags": "[parameters('tags')]", @@ -2046,6 +2150,200 @@ "dependsOn": [ "kustoCluster" ] + }, + "kustoCluster_databases": { + "copy": { + "name": "kustoCluster_databases", + "count": "[length(coalesce(parameters('databases'), createArray()))]" + }, + "type": "Microsoft.Resources/deployments", + "apiVersion": "2022-09-01", + "name": "[format('{0}-kustoCluster-database-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]", + "properties": { + "expressionEvaluationOptions": { + "scope": "inner" + }, + "mode": "Incremental", + "parameters": { + "name": { + "value": "[coalesce(parameters('databases'), createArray())[copyIndex()].name]" + }, + "kustoClusterName": { + "value": "[parameters('name')]" + }, + "databaseKind": { + "value": "[coalesce(parameters('databases'), createArray())[copyIndex()].kind]" + }, + "databaseReadWriteProperties": "[if(equals(coalesce(parameters('databases'), createArray())[copyIndex()].kind, 'ReadWrite'), createObject('value', coalesce(parameters('databases'), createArray())[copyIndex()].readWriteProperties), createObject('value', null()))]" + }, + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "languageVersion": "2.0", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.32.4.45862", + "templateHash": "18422341525898722212" + }, + "name": "Kusto Cluster Databases", + "description": "This module deploys a Kusto Cluster Database.", + "owner": "Azure/module-maintainers" + }, + "definitions": { + "databaseReadWriteType": { + "type": "object", + "properties": { + "hotCachePeriod": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. Te time the data should be kept in cache for fast queries in TimeSpan." + } + }, + "keyVaultProperties": { + "type": "object", + "properties": { + "keyName": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The name of the key." + } + }, + "keyVaultUri": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The Uri of the key vault." + } + }, + "keyVersion": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The version of the key." + } + }, + "userIdentity": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The user identity." + } + } + }, + "nullable": true, + "metadata": { + "description": "Optional. The properties of the key vault." + } + }, + "softDeletePeriod": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The time the data should be kept before it stops being accessible to queries in TimeSpan." + } + } + }, + "nullable": true, + "metadata": { + "__bicep_export!": true, + "description": "Conditional. The properties of the database if using read-write." + } + } + }, + "parameters": { + "name": { + "type": "string", + "metadata": { + "description": "Required. The name of the Kusto Cluster database." + } + }, + "kustoClusterName": { + "type": "string", + "metadata": { + "description": "Conditional. The name of the parent Kusto Cluster. Required if the template is used in a standalone deployment." + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "Optional. Location for the databases." + } + }, + "databaseKind": { + "type": "string", + "defaultValue": "ReadWrite", + "allowedValues": [ + "ReadWrite", + "ReadOnlyFollowing" + ], + "metadata": { + "description": "Optional. The object type of the databse." + } + }, + "databaseReadWriteProperties": { + "$ref": "#/definitions/databaseReadWriteType", + "metadata": { + "description": "Optional. The properties of the database if using read-write. Only used if databaseKind is ReadWrite." + } + } + }, + "resources": { + "kustoCluster": { + "existing": true, + "type": "Microsoft.Kusto/clusters", + "apiVersion": "2024-04-13", + "name": "[parameters('kustoClusterName')]" + }, + "database_readOnly": { + "condition": "[equals(parameters('databaseKind'), 'ReadOnlyFollowing')]", + "type": "Microsoft.Kusto/clusters/databases", + "apiVersion": "2024-04-13", + "name": "[format('{0}/{1}', parameters('kustoClusterName'), parameters('name'))]", + "location": "[parameters('location')]", + "kind": "ReadOnlyFollowing" + }, + "database_readWrite": { + "condition": "[equals(parameters('databaseKind'), 'ReadWrite')]", + "type": "Microsoft.Kusto/clusters/databases", + "apiVersion": "2024-04-13", + "name": "[format('{0}/{1}', parameters('kustoClusterName'), parameters('name'))]", + "location": "[parameters('location')]", + "kind": "ReadWrite", + "properties": "[coalesce(parameters('databaseReadWriteProperties'), null())]" + } + }, + "outputs": { + "name": { + "type": "string", + "metadata": { + "description": "The name of the Kusto Cluster database." + }, + "value": "[if(equals(parameters('databaseKind'), 'ReadOnlyFollowing'), parameters('name'), parameters('name'))]" + }, + "resourceId": { + "type": "string", + "metadata": { + "description": "The resource ID of the Kusto Cluster database." + }, + "value": "[if(equals(parameters('databaseKind'), 'ReadOnlyFollowing'), resourceId('Microsoft.Kusto/clusters/databases', parameters('kustoClusterName'), parameters('name')), resourceId('Microsoft.Kusto/clusters/databases', parameters('kustoClusterName'), parameters('name')))]" + }, + "resourceGroupName": { + "type": "string", + "metadata": { + "description": "The resource group containing the Kusto Cluster database." + }, + "value": "[resourceGroup().name]" + } + } + } + }, + "dependsOn": [ + "kustoCluster" + ] } }, "outputs": { @@ -2069,7 +2367,7 @@ "metadata": { "description": "The principal ID of the system assigned identity." }, - "value": "[tryGet(tryGet(reference('kustoCluster', '2023-08-15', 'full'), 'identity'), 'principalId')]" + "value": "[tryGet(tryGet(reference('kustoCluster', '2024-04-13', 'full'), 'identity'), 'principalId')]" }, "name": { "type": "string", @@ -2083,7 +2381,7 @@ "metadata": { "description": "The location the resource was deployed into." }, - "value": "[reference('kustoCluster', '2023-08-15', 'full').location]" + "value": "[reference('kustoCluster', '2024-04-13', 'full').location]" }, "privateEndpoints": { "type": "array", @@ -2100,6 +2398,19 @@ "networkInterfaceIds": "[reference(format('kustoCluster_privateEndpoints[{0}]', copyIndex())).outputs.networkInterfaceIds.value]" } } + }, + "databases": { + "type": "array", + "metadata": { + "description": "The databases of the kusto cluster." + }, + "copy": { + "count": "[length(if(not(empty(parameters('databases'))), array(parameters('databases')), createArray()))]", + "input": { + "name": "[reference(format('kustoCluster_databases[{0}]', copyIndex())).outputs.name.value]", + "resourceId": "[reference(format('kustoCluster_databases[{0}]', copyIndex())).outputs.resourceId.value]" + } + } } } } \ No newline at end of file diff --git a/avm/res/kusto/cluster/tests/e2e/defaults/dependencies.bicep b/avm/res/kusto/cluster/tests/e2e/defaults/dependencies.bicep new file mode 100644 index 0000000000..790303be68 --- /dev/null +++ b/avm/res/kusto/cluster/tests/e2e/defaults/dependencies.bicep @@ -0,0 +1,19 @@ +@description('Required. The location to deploy resources to.') +param location string = resourceGroup().location + +@description('Required. The name of the managed identity to create.') +param managedIdentityName string + +resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { + name: managedIdentityName + location: location +} + +@description('The resource ID of the created Managed Identity.') +output managedIdentityResourceId string = managedIdentity.id + +@description('The principal ID of the created Managed Identity.') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId + +@description('The client ID of the created Managed Identity.') +output managedIdentityClientId string = managedIdentity.properties.clientId diff --git a/avm/res/kusto/cluster/tests/e2e/defaults/main.test.bicep b/avm/res/kusto/cluster/tests/e2e/defaults/main.test.bicep index 92f34c9927..eaacaa65ff 100644 --- a/avm/res/kusto/cluster/tests/e2e/defaults/main.test.bicep +++ b/avm/res/kusto/cluster/tests/e2e/defaults/main.test.bicep @@ -31,6 +31,16 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2024-03-01' = { location: resourceLocation } +module nestedDependencies 'dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, resourceLocation)}-paramNested' + params: { + location: resourceLocation + managedIdentityName: 'dep-${namePrefix}-msi-${serviceShort}' + // entraIdGroupName: 'dep-${namePrefix}-group-${serviceShort}' + } +} + // ============== // // Test Execution // // ============== // @@ -44,6 +54,12 @@ module testDeployment '../../../main.bicep' = [ name: '${namePrefix}${serviceShort}0001' location: resourceLocation sku: 'Standard_E2ads_v5' + enableDiskEncryption: true + managedIdentities: { + userAssignedResourceIds: [ + nestedDependencies.outputs.managedIdentityResourceId + ] + } } } ] diff --git a/avm/res/kusto/cluster/tests/e2e/max/main.test.bicep b/avm/res/kusto/cluster/tests/e2e/max/main.test.bicep index 93be9a10ff..edc2c27ea0 100644 --- a/avm/res/kusto/cluster/tests/e2e/max/main.test.bicep +++ b/avm/res/kusto/cluster/tests/e2e/max/main.test.bicep @@ -117,6 +117,16 @@ module testDeployment '../../../main.bicep' = [ principalType: 'ServicePrincipal' } ] + databases: [ + { + name: 'myReadWriteDatabase' + kind: 'ReadWrite' + readWriteProperties: { + softDeletePeriod: 'P7D' + hotCachePeriod: 'P1D' + } + } + ] } } ] diff --git a/avm/res/kusto/cluster/version.json b/avm/res/kusto/cluster/version.json index 13669e6601..41fc8c654f 100644 --- a/avm/res/kusto/cluster/version.json +++ b/avm/res/kusto/cluster/version.json @@ -1,7 +1,7 @@ { "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", - "version": "0.4", + "version": "0.5", "pathFilters": [ "./main.json" ] -} \ No newline at end of file +}