Skip to content

Commit

Permalink
fix: Resolve failing tests (Azure#2876)
Browse files Browse the repository at this point in the history
## Description

Update API version for all modules. Disable
Azure.MySQL.MaintenanceWindow check due to bug with resource provider.
Enforce ZoneRedundancy as default. Update default version from 5.7 to
8.0. Use dedicated location for all tests.

Fixes Azure#1649 
Closes Azure#1649 


## Pipeline Reference

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

| Pipeline |
| -------- |

[![avm.res.db-for-my-sql.flexible-server](https://github.com/hundredacres/bicep-registry-modules/actions/workflows/avm.res.db-for-my-sql.flexible-server.yml/badge.svg?branch=fix%2Fdb-for-mysql%2Fflexible%2F1649&event=workflow_dispatch)](https://github.com/hundredacres/bicep-registry-modules/actions/workflows/avm.res.db-for-my-sql.flexible-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)
- [X] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [X] 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
- [XI 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 -->

---------

Signed-off-by: PixelRobots <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Máté Barabás <[email protected]>
Co-authored-by: Rainer Halanek <[email protected]>
Co-authored-by: JFolberth <[email protected]>
Co-authored-by: Alexander Sehr <[email protected]>
Co-authored-by: Erika Gressi <[email protected]>
Co-authored-by: Zach Trocinski <[email protected]>
Co-authored-by: Christoph Vollmann <[email protected]>
Co-authored-by: René Hézser <[email protected]>
Co-authored-by: emichellecarter <[email protected]>
Co-authored-by: Michelle Carter <[email protected]>
Co-authored-by: elisa anzelmo <[email protected]>
Co-authored-by: rodney-almeida <[email protected]>
Co-authored-by: Rodney Almeida <[email protected]>
Co-authored-by: ChrisSidebotham-MSFT <[email protected]>
Co-authored-by: Richard Hooper <[email protected]>
Co-authored-by: Ilhaan Rasheed <[email protected]>
Co-authored-by: Axel B. Andersen <[email protected]>
Co-authored-by: Javier Cevallos <[email protected]>
Co-authored-by: Ahmad Abdalla <[email protected]>
Co-authored-by: Kris Baranek <[email protected]>
Co-authored-by: Peter Budai <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: MichielVanHerreweghe <[email protected]>
Co-authored-by: Axel B. Andersen <[email protected]>
Co-authored-by: Bryan <[email protected]>
Co-authored-by: Zach Trocinski <[email protected]>
Co-authored-by: Seif Bassem <[email protected]>
Co-authored-by: Jack Tracey <[email protected]>
Co-authored-by: Guillaume Beaud <[email protected]>
Co-authored-by: Sebastian Gräf <[email protected]>
Co-authored-by: Jose Arias CSA <[email protected]>
Co-authored-by: John <[email protected]>
Co-authored-by: judyer28 <[email protected]>
Co-authored-by: Buddy <[email protected]>
Co-authored-by: bobmclane999 <[email protected]>
Co-authored-by: Fabio Masciotra <[email protected]>
Co-authored-by: Wenjie Yu(MSFT) <[email protected]>
Co-authored-by: zedy <[email protected]>
Co-authored-by: Clint Grove <[email protected]>
Co-authored-by: Matt Hoffmeister <[email protected]>
Co-authored-by: Nate Arnold <[email protected]>
Co-authored-by: Luke Snoddy <[email protected]>
Co-authored-by: Dany Contreras <[email protected]>
Co-authored-by: danycontre <[email protected]>
Co-authored-by: Pankaj Agrawal <[email protected]>
Co-authored-by: Maher Aldineh <[email protected]>
Co-authored-by: Tony Box <[email protected]>
Co-authored-by: Tony Box <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 92 deletions.
57 changes: 43 additions & 14 deletions avm/res/db-for-my-sql/flexible-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ This module deploys a DBforMySQL Flexible Server.
| :-- | :-- |
| `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.DBforMySQL/flexibleServers` | [2022-09-30-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2022-09-30-preview/flexibleServers) |
| `Microsoft.DBforMySQL/flexibleServers/administrators` | [2022-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2022-01-01/flexibleServers/administrators) |
| `Microsoft.DBforMySQL/flexibleServers/databases` | [2022-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2022-01-01/flexibleServers/databases) |
| `Microsoft.DBforMySQL/flexibleServers/firewallRules` | [2022-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2022-01-01/flexibleServers/firewallRules) |
| `Microsoft.DBforMySQL/flexibleServers` | [2023-12-30](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/flexibleServers) |
| `Microsoft.DBforMySQL/flexibleServers/administrators` | [2023-06-30](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2023-06-30/flexibleServers/administrators) |
| `Microsoft.DBforMySQL/flexibleServers/databases` | [2023-06-30](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2023-06-30/flexibleServers/databases) |
| `Microsoft.DBforMySQL/flexibleServers/firewallRules` | [2023-06-30](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2023-06-30/flexibleServers/firewallRules) |
| `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) |

## Usage examples
Expand Down Expand Up @@ -51,12 +51,13 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
params: {
// Required parameters
name: 'dfmsfsmin001'
skuName: 'Standard_B1ms'
tier: 'Burstable'
skuName: 'Standard_D2ds_v4'
tier: 'GeneralPurpose'
// Non-required parameters
administratorLogin: 'adminUserName'
administratorLoginPassword: '<administratorLoginPassword>'
location: '<location>'
storageAutoGrow: 'Enabled'
}
}
```
Expand All @@ -78,10 +79,10 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
"value": "dfmsfsmin001"
},
"skuName": {
"value": "Standard_B1ms"
"value": "Standard_D2ds_v4"
},
"tier": {
"value": "Burstable"
"value": "GeneralPurpose"
},
// Non-required parameters
"administratorLogin": {
Expand All @@ -92,6 +93,9 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
},
"location": {
"value": "<location>"
},
"storageAutoGrow": {
"value": "Enabled"
}
}
}
Expand Down Expand Up @@ -535,16 +539,20 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
params: {
// Required parameters
name: 'dfmswaf001'
skuName: 'Standard_B1ms'
tier: 'Burstable'
skuName: 'Standard_D2ds_v4'
tier: 'GeneralPurpose'
// Non-required parameters
administratorLogin: 'adminUserName'
administratorLoginPassword: '<administratorLoginPassword>'
availabilityZone: '1'
highAvailability: 'ZoneRedundant'
highAvailabilityZone: '2'
location: '<location>'
lock: {
kind: 'CanNotDelete'
name: 'myCustomLockName'
}
storageAutoGrow: 'Enabled'
tags: {
Environment: 'Non-Prod'
'hidden-title': 'This is visible in the resource name'
Expand All @@ -571,10 +579,10 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
"value": "dfmswaf001"
},
"skuName": {
"value": "Standard_B1ms"
"value": "Standard_D2ds_v4"
},
"tier": {
"value": "Burstable"
"value": "GeneralPurpose"
},
// Non-required parameters
"administratorLogin": {
Expand All @@ -583,6 +591,15 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
"administratorLoginPassword": {
"value": "<administratorLoginPassword>"
},
"availabilityZone": {
"value": "1"
},
"highAvailability": {
"value": "ZoneRedundant"
},
"highAvailabilityZone": {
"value": "2"
},
"location": {
"value": "<location>"
},
Expand All @@ -592,6 +609,9 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
"name": "myCustomLockName"
}
},
"storageAutoGrow": {
"value": "Enabled"
},
"tags": {
"value": {
"Environment": "Non-Prod",
Expand Down Expand Up @@ -646,6 +666,7 @@ module flexibleServer 'br/public:avm/res/db-for-my-sql/flexible-server:<version>
| [`firewallRules`](#parameter-firewallrules) | array | The firewall rules to create in the MySQL flexible server. |
| [`geoRedundantBackup`](#parameter-georedundantbackup) | string | A value indicating whether Geo-Redundant backup is enabled on the server. If "Enabled" and "cMKKeyName" is not empty, then "geoBackupCMKKeyVaultResourceId" and "cMKUserAssignedIdentityResourceId" are also required. |
| [`highAvailability`](#parameter-highavailability) | string | The mode for High Availability (HA). It is not supported for the Burstable pricing tier and Zone redundant HA can only be set during server provisioning. |
| [`highAvailabilityZone`](#parameter-highavailabilityzone) | string | Standby availability zone information of the server. Default will have no preference set. |
| [`location`](#parameter-location) | string | Location for all resources. |
| [`lock`](#parameter-lock) | object | The lock settings of the service. |
| [`maintenanceWindow`](#parameter-maintenancewindow) | object | Properties for the maintenence window. If provided, "customWindow" property must exist and set to "Enabled". |
Expand Down Expand Up @@ -1108,7 +1129,7 @@ The mode for High Availability (HA). It is not supported for the Burstable prici

- Required: No
- Type: string
- Default: `'Disabled'`
- Default: `'ZoneRedundant'`
- Allowed:
```Bicep
[
Expand All @@ -1118,6 +1139,14 @@ The mode for High Availability (HA). It is not supported for the Burstable prici
]
```

### Parameter: `highAvailabilityZone`

Standby availability zone information of the server. Default will have no preference set.

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

### Parameter: `location`

Location for all resources.
Expand Down Expand Up @@ -1335,7 +1364,7 @@ MySQL Server version.

- Required: No
- Type: string
- Default: `'5.7'`
- Default: `'8.0.21'`
- Allowed:
```Bicep
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This module deploys a DBforMySQL Flexible Server Administrator.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.DBforMySQL/flexibleServers/administrators` | [2022-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2022-01-01/flexibleServers/administrators) |
| `Microsoft.DBforMySQL/flexibleServers/administrators` | [2023-06-30](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2023-06-30/flexibleServers/administrators) |

## Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ param login string
@description('Optional. The tenantId of the Active Directory administrator.')
param tenantId string = tenant().tenantId

resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2022-01-01' existing = {
resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2023-12-30' existing = {
name: flexibleServerName
}

resource administrator 'Microsoft.DBforMySQL/flexibleServers/administrators@2022-01-01' = {
resource administrator 'Microsoft.DBforMySQL/flexibleServers/administrators@2023-06-30' = {
name: 'ActiveDirectory'
parent: flexibleServer
properties: {
Expand Down
6 changes: 3 additions & 3 deletions avm/res/db-for-my-sql/flexible-server/administrator/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "2817201491275445304"
"version": "0.28.1.47646",
"templateHash": "6790232868083578968"
},
"name": "DBforMySQL Flexible Server Administrators",
"description": "This module deploys a DBforMySQL Flexible Server Administrator.",
Expand Down Expand Up @@ -47,7 +47,7 @@
"resources": [
{
"type": "Microsoft.DBforMySQL/flexibleServers/administrators",
"apiVersion": "2022-01-01",
"apiVersion": "2023-06-30",
"name": "[format('{0}/{1}', parameters('flexibleServerName'), 'ActiveDirectory')]",
"properties": {
"administratorType": "ActiveDirectory",
Expand Down
2 changes: 1 addition & 1 deletion avm/res/db-for-my-sql/flexible-server/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This module deploys a DBforMySQL Flexible Server Database.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.DBforMySQL/flexibleServers/databases` | [2022-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2022-01-01/flexibleServers/databases) |
| `Microsoft.DBforMySQL/flexibleServers/databases` | [2023-06-30](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2023-06-30/flexibleServers/databases) |

## Parameters

Expand Down
4 changes: 2 additions & 2 deletions avm/res/db-for-my-sql/flexible-server/database/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ param collation string = 'utf8'
@description('Optional. The charset of the database.')
param charset string = 'utf8_general_ci'

resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2022-09-30-preview' existing = {
resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2023-12-30' existing = {
name: flexibleServerName
}

resource database 'Microsoft.DBforMySQL/flexibleServers/databases@2022-01-01' = {
resource database 'Microsoft.DBforMySQL/flexibleServers/databases@2023-06-30' = {
name: name
parent: flexibleServer
properties: {
Expand Down
6 changes: 3 additions & 3 deletions avm/res/db-for-my-sql/flexible-server/database/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "9734848552595709363"
"version": "0.28.1.47646",
"templateHash": "10336036524933085246"
},
"name": "DBforMySQL Flexible Server Databases",
"description": "This module deploys a DBforMySQL Flexible Server Database.",
Expand Down Expand Up @@ -42,7 +42,7 @@
"resources": [
{
"type": "Microsoft.DBforMySQL/flexibleServers/databases",
"apiVersion": "2022-01-01",
"apiVersion": "2023-06-30",
"name": "[format('{0}/{1}', parameters('flexibleServerName'), parameters('name'))]",
"properties": {
"collation": "[if(not(empty(parameters('collation'))), parameters('collation'), null())]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This module deploys a DBforMySQL Flexible Server Firewall Rule.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.DBforMySQL/flexibleServers/firewallRules` | [2022-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2022-01-01/flexibleServers/firewallRules) |
| `Microsoft.DBforMySQL/flexibleServers/firewallRules` | [2023-06-30](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DBforMySQL/2023-06-30/flexibleServers/firewallRules) |

## Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ param endIpAddress string
@description('Conditional. The name of the parent MySQL flexible server. Required if the template is used in a standalone deployment.')
param flexibleServerName string

resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2022-09-30-preview' existing = {
resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2023-12-30' existing = {
name: flexibleServerName
}

resource firewallRule 'Microsoft.DBforMySQL/flexibleServers/firewallRules@2022-01-01' = {
resource firewallRule 'Microsoft.DBforMySQL/flexibleServers/firewallRules@2023-06-30' = {
name: name
parent: flexibleServer
properties: {
Expand Down
6 changes: 3 additions & 3 deletions avm/res/db-for-my-sql/flexible-server/firewall-rule/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "2931317814738693960"
"version": "0.28.1.47646",
"templateHash": "15749635080430899727"
},
"name": "DBforMySQL Flexible Server Firewall Rules",
"description": "This module deploys a DBforMySQL Flexible Server Firewall Rule.",
Expand Down Expand Up @@ -40,7 +40,7 @@
"resources": [
{
"type": "Microsoft.DBforMySQL/flexibleServers/firewallRules",
"apiVersion": "2022-01-01",
"apiVersion": "2023-06-30",
"name": "[format('{0}/{1}', parameters('flexibleServerName'), parameters('name'))]",
"properties": {
"endIpAddress": "[parameters('endIpAddress')]",
Expand Down
20 changes: 15 additions & 5 deletions avm/res/db-for-my-sql/flexible-server/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ param tier string
@description('Optional. Availability zone information of the server. Default will have no preference set.')
param availabilityZone string = ''

@description('Optional. Standby availability zone information of the server. Default will have no preference set.')
param highAvailabilityZone string = ''

@minValue(1)
@maxValue(35)
@description('Optional. Backup retention days for the server.')
Expand Down Expand Up @@ -80,7 +83,7 @@ param customerManagedKeyGeo customerManagedKeyType
'ZoneRedundant'
])
@description('Optional. The mode for High Availability (HA). It is not supported for the Burstable pricing tier and Zone redundant HA can only be set during server provisioning.')
param highAvailability string = 'Disabled'
param highAvailability string = 'ZoneRedundant'

@description('Optional. Properties for the maintenence window. If provided, "customWindow" property must exist and set to "Enabled".')
param maintenanceWindow object = {}
Expand Down Expand Up @@ -145,7 +148,7 @@ param storageSizeGB int = 64
'8.0.21'
])
@description('Optional. MySQL Server version.')
param version string = '5.7'
param version string = '8.0.21'

@description('Optional. The databases to create in the server.')
param databases array = []
Expand All @@ -162,6 +165,14 @@ param diagnosticSettings diagnosticSettingType
@description('Optional. Enable/Disable usage telemetry for module.')
param enableTelemetry bool = true

var standByAvailabilityZoneTable = {
Disabled: null
SameZone: availabilityZone
ZoneRedundant: highAvailabilityZone
}

var standByAvailabilityZone = standByAvailabilityZoneTable[?highAvailability]

var formattedUserAssignedIdentities = reduce(
map((managedIdentities.?userAssignedResourceIds ?? []), (id) => { '${id}': {} }),
{},
Expand Down Expand Up @@ -193,7 +204,6 @@ var builtInRoleNames = {
)
}

#disable-next-line no-deployments-resources
resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableTelemetry) {
name: '46d3xbcp.res.dbformysql-flexibleserver.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}'
properties: {
Expand Down Expand Up @@ -252,7 +262,7 @@ resource cMKGeoUserAssignedIdentity 'Microsoft.ManagedIdentity/userAssignedIdent
)
}

resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2022-09-30-preview' = {
resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2023-12-30' = {
name: name
location: location
tags: tags
Expand Down Expand Up @@ -287,7 +297,7 @@ resource flexibleServer 'Microsoft.DBforMySQL/flexibleServers@2022-09-30-preview
: null
highAvailability: {
mode: highAvailability
standbyAvailabilityZone: highAvailability == 'SameZone' ? availabilityZone : null
standbyAvailabilityZone: standByAvailabilityZone
}
maintenanceWindow: !empty(maintenanceWindow)
? {
Expand Down
Loading

0 comments on commit ef47460

Please sign in to comment.