Skip to content

Commit

Permalink
feat: Update SQL Server API - avm/res/sql/server (#3325)
Browse files Browse the repository at this point in the history
* Add support for enabling IPv6 in SQL server
* Update allowed values for publicNetworkAccess
* Refactor parameter assignments to fix linter warnings

## Description

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.sql.server](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.sql.server.yml/badge.svg)](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.sql.server.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [ ] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [x] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->
  • Loading branch information
peterbud authored Oct 13, 2024
1 parent 016b727 commit 341743c
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 244 deletions.
21 changes: 18 additions & 3 deletions avm/res/sql/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ module server 'br/public:avm/res/sql/server:<version>' = {
]
elasticPools: [
{
maintenanceConfigurationId: '<maintenanceConfigurationId>'
name: 'sqlsmax-ep-001'
skuCapacity: 10
skuName: 'GP_Gen5'
Expand Down Expand Up @@ -641,7 +640,6 @@ module server 'br/public:avm/res/sql/server:<version>' = {
"elasticPools": {
"value": [
{
"maintenanceConfigurationId": "<maintenanceConfigurationId>",
"name": "sqlsmax-ep-001",
"skuCapacity": 10,
"skuName": "GP_Gen5",
Expand Down Expand Up @@ -829,7 +827,6 @@ param databases = [
]
param elasticPools = [
{
maintenanceConfigurationId: '<maintenanceConfigurationId>'
name: 'sqlsmax-ep-001'
skuCapacity: 10
skuName: 'GP_Gen5'
Expand Down Expand Up @@ -1680,6 +1677,7 @@ param vulnerabilityAssessmentsObj = {
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
| [`encryptionProtectorObj`](#parameter-encryptionprotectorobj) | object | The encryption protection configuration. |
| [`firewallRules`](#parameter-firewallrules) | array | The firewall rules to create in the server. |
| [`isIPv6Enabled`](#parameter-isipv6enabled) | string | Whether or not to enable IPv6 support for this server. |
| [`keys`](#parameter-keys) | array | The keys to configure. |
| [`location`](#parameter-location) | string | Location for all resources. |
| [`lock`](#parameter-lock) | object | The lock settings of the service. |
Expand Down Expand Up @@ -1878,6 +1876,21 @@ The firewall rules to create in the server.
- Type: array
- Default: `[]`

### Parameter: `isIPv6Enabled`

Whether or not to enable IPv6 support for this server.

- Required: No
- Type: string
- Default: `'Disabled'`
- Allowed:
```Bicep
[
'Disabled'
'Enabled'
]
```

### Parameter: `keys`

The keys to configure.
Expand Down Expand Up @@ -1971,6 +1984,7 @@ Minimal TLS version allowed.
'1.0'
'1.1'
'1.2'
'1.3'
]
```

Expand Down Expand Up @@ -2393,6 +2407,7 @@ Whether or not public network access is allowed for this resource. For security
''
'Disabled'
'Enabled'
'SecuredByPerimeter'
]
```

Expand Down
1 change: 0 additions & 1 deletion avm/res/sql/server/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ Maintenance configuration ID assigned to the database. This configuration define

- Required: No
- Type: string
- Default: `''`

### Parameter: `maxSizeBytes`

Expand Down
26 changes: 8 additions & 18 deletions avm/res/sql/server/database/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ param requestedBackupStorageRedundancy string = ''
param isLedgerOn bool = false

@description('Optional. Maintenance configuration ID assigned to the database. This configuration defines the period when the maintenance updates will occur.')
param maintenanceConfigurationId string = ''
param maintenanceConfigurationId string?

@description('Optional. The short term backup retention policy to create for the database.')
param backupShortTermRetentionPolicy object = {}
Expand Down Expand Up @@ -164,7 +164,7 @@ resource database 'Microsoft.Sql/servers/databases@2023-08-01-preview' = {
highAvailabilityReplicaCount: highAvailabilityReplicaCount
requestedBackupStorageRedundancy: any(requestedBackupStorageRedundancy)
isLedgerOn: isLedgerOn
maintenanceConfigurationId: !empty(maintenanceConfigurationId) ? maintenanceConfigurationId : null
maintenanceConfigurationId: maintenanceConfigurationId
elasticPoolId: elasticPoolId
createMode: createMode
sourceDatabaseId: !empty(sourceDatabaseResourceId) ? sourceDatabaseResourceId : null
Expand Down Expand Up @@ -211,12 +211,8 @@ module database_backupShortTermRetentionPolicy 'backup-short-term-retention-poli
params: {
serverName: serverName
databaseName: database.name
diffBackupIntervalInHours: contains(backupShortTermRetentionPolicy, 'diffBackupIntervalInHours')
? backupShortTermRetentionPolicy.diffBackupIntervalInHours
: 24
retentionDays: contains(backupShortTermRetentionPolicy, 'retentionDays')
? backupShortTermRetentionPolicy.retentionDays
: 7
diffBackupIntervalInHours: backupShortTermRetentionPolicy.?diffBackupIntervalInHours ?? 24
retentionDays: backupShortTermRetentionPolicy.?retentionDays ?? 7
}
}

Expand All @@ -225,16 +221,10 @@ module database_backupLongTermRetentionPolicy 'backup-long-term-retention-policy
params: {
serverName: serverName
databaseName: database.name
weeklyRetention: contains(backupLongTermRetentionPolicy, 'weeklyRetention')
? backupLongTermRetentionPolicy.weeklyRetention
: ''
monthlyRetention: contains(backupLongTermRetentionPolicy, 'monthlyRetention')
? backupLongTermRetentionPolicy.monthlyRetention
: ''
yearlyRetention: contains(backupLongTermRetentionPolicy, 'yearlyRetention')
? backupLongTermRetentionPolicy.yearlyRetention
: ''
weekOfYear: contains(backupLongTermRetentionPolicy, 'weekOfYear') ? backupLongTermRetentionPolicy.weekOfYear : 1
weeklyRetention: backupLongTermRetentionPolicy.?weeklyRetention ?? ''
monthlyRetention: backupLongTermRetentionPolicy.?monthlyRetention ?? ''
yearlyRetention: backupLongTermRetentionPolicy.?yearlyRetention ?? ''
weekOfYear: backupLongTermRetentionPolicy.?weekOfYear ?? 1
}
}

Expand Down
30 changes: 21 additions & 9 deletions avm/res/sql/server/database/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "6019999815954957727"
"templateHash": "18021918128213514276"
},
"name": "SQL Server Database",
"description": "This module deploys an Azure SQL Server Database.",
Expand Down Expand Up @@ -355,7 +355,7 @@
},
"maintenanceConfigurationId": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Maintenance configuration ID assigned to the database. This configuration defines the period when the maintenance updates will occur."
}
Expand Down Expand Up @@ -404,7 +404,7 @@
"highAvailabilityReplicaCount": "[parameters('highAvailabilityReplicaCount')]",
"requestedBackupStorageRedundancy": "[parameters('requestedBackupStorageRedundancy')]",
"isLedgerOn": "[parameters('isLedgerOn')]",
"maintenanceConfigurationId": "[if(not(empty(parameters('maintenanceConfigurationId'))), parameters('maintenanceConfigurationId'), null())]",
"maintenanceConfigurationId": "[parameters('maintenanceConfigurationId')]",
"elasticPoolId": "[parameters('elasticPoolId')]",
"createMode": "[parameters('createMode')]",
"sourceDatabaseId": "[if(not(empty(parameters('sourceDatabaseResourceId'))), parameters('sourceDatabaseResourceId'), null())]",
Expand Down Expand Up @@ -474,8 +474,12 @@
"databaseName": {
"value": "[parameters('name')]"
},
"diffBackupIntervalInHours": "[if(contains(parameters('backupShortTermRetentionPolicy'), 'diffBackupIntervalInHours'), createObject('value', parameters('backupShortTermRetentionPolicy').diffBackupIntervalInHours), createObject('value', 24))]",
"retentionDays": "[if(contains(parameters('backupShortTermRetentionPolicy'), 'retentionDays'), createObject('value', parameters('backupShortTermRetentionPolicy').retentionDays), createObject('value', 7))]"
"diffBackupIntervalInHours": {
"value": "[coalesce(tryGet(parameters('backupShortTermRetentionPolicy'), 'diffBackupIntervalInHours'), 24)]"
},
"retentionDays": {
"value": "[coalesce(tryGet(parameters('backupShortTermRetentionPolicy'), 'retentionDays'), 7)]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
Expand Down Expand Up @@ -574,10 +578,18 @@
"databaseName": {
"value": "[parameters('name')]"
},
"weeklyRetention": "[if(contains(parameters('backupLongTermRetentionPolicy'), 'weeklyRetention'), createObject('value', parameters('backupLongTermRetentionPolicy').weeklyRetention), createObject('value', ''))]",
"monthlyRetention": "[if(contains(parameters('backupLongTermRetentionPolicy'), 'monthlyRetention'), createObject('value', parameters('backupLongTermRetentionPolicy').monthlyRetention), createObject('value', ''))]",
"yearlyRetention": "[if(contains(parameters('backupLongTermRetentionPolicy'), 'yearlyRetention'), createObject('value', parameters('backupLongTermRetentionPolicy').yearlyRetention), createObject('value', ''))]",
"weekOfYear": "[if(contains(parameters('backupLongTermRetentionPolicy'), 'weekOfYear'), createObject('value', parameters('backupLongTermRetentionPolicy').weekOfYear), createObject('value', 1))]"
"weeklyRetention": {
"value": "[coalesce(tryGet(parameters('backupLongTermRetentionPolicy'), 'weeklyRetention'), '')]"
},
"monthlyRetention": {
"value": "[coalesce(tryGet(parameters('backupLongTermRetentionPolicy'), 'monthlyRetention'), '')]"
},
"yearlyRetention": {
"value": "[coalesce(tryGet(parameters('backupLongTermRetentionPolicy'), 'yearlyRetention'), '')]"
},
"weekOfYear": {
"value": "[coalesce(tryGet(parameters('backupLongTermRetentionPolicy'), 'weekOfYear'), 1)]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
Expand Down
1 change: 0 additions & 1 deletion avm/res/sql/server/elastic-pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ Maintenance configuration resource ID assigned to the elastic pool. This configu

- Required: No
- Type: string
- Default: `''`

### Parameter: `maxSizeBytes`

Expand Down
2 changes: 1 addition & 1 deletion avm/res/sql/server/elastic-pool/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ param highAvailabilityReplicaCount int?
param licenseType string = 'LicenseIncluded'

@description('Optional. Maintenance configuration resource ID assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur.')
param maintenanceConfigurationId string = ''
param maintenanceConfigurationId string?

@description('Optional. The storage limit for the database elastic pool in bytes.')
param maxSizeBytes int = 34359738368
Expand Down
4 changes: 2 additions & 2 deletions avm/res/sql/server/elastic-pool/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "18037703368269722870"
"templateHash": "17774091526328280898"
},
"name": "SQL Server Elastic Pool",
"description": "This module deploys an Azure SQL Server Elastic Pool.",
Expand Down Expand Up @@ -80,7 +80,7 @@
},
"maintenanceConfigurationId": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Maintenance configuration resource ID assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur."
}
Expand Down
Loading

0 comments on commit 341743c

Please sign in to comment.