Azure / Azure/bicep-registry-modules

[AVM Module Issue]: Quality of Life for DBforMySQL/flexibleServers

Open
#3,719 9 comments 0 reactions 1 assignee Claimed by @abhishekaryams View on GitHub
Class: Resource Module :package: Needs: Immediate Attention :bangbang: Needs: Triage :mag: Status: Response Overdue :triangular_flag_on_post: Type: AVM :a: :v: :m: Type: Feature Request :heavy_plus_sign:
Dominant language
Bicep
Stars
736
Forks
564
Avg merge
3d 15h
Merged PRs (30d)
30

Description

### Check for previous/existing GitHub issues

- [x] I have checked for previous/existing GitHub issues

### Issue Type?

Feature Request

### Module Name

avm/res/db-for-my-sql/flexible-server

### (Optional) Module Version

_No response_

### Description

I’m really looking for is a self-healing mechanism that operates behind the scenes. Specifically, I want the module to avoid errors when I choose the Burstable tier for cost reasons, even though this requires disabling storageAutoGrow. On the other hand, if I select a different tier and want to keep storageAutoGrow enabled, I want everything to function smoothly. storageAutoGrow must be disabled if Burstable tier is used as it is not supported.

This is viable for when I am doing code testing or a PoC, because I want to keep cost down as I rip the workload up/down.

My suggestion would be something like this but would need to be verified if it works.
 
```
// Ensure highAvailability is set to 'Disabled' if tier is 'Burstable'
var effectiveHighAvailability = (tier == 'Burstable') ? 'Disabled' : highAvailability

// Ensure storageAutoGrow is disabled if tier is 'Burstable' and highAvailability is 'SameZone' or 'ZoneRedundant'
var effectiveStorageAutoGrow = (tier == 'Burstable' && (highAvailability == 'SameZone' || highAvailability == 'ZoneRedundant')) ? 'Disabled' : storageAutoGrow

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

var standByAvailabilityZone = standByAvailabilityZoneTable[effectiveHighAvailability]

storageProfile: {
storageMB: 51200
backupRetentionDays: 7
geoRedundantBackup: 'Enabled'
autoGrow: effectiveStorageAutoGrow
}
highAvailability: (effectiveHighAvailability != 'Disabled') ? {
mode: effectiveHighAvailability
standbyAvailabilityZone: standByAvailabilityZone
} : null

```

**Self-Healing Mechanism**
**Avoiding Errors:** By conditionally setting `effectiveHighAvailability `and `effectiveStorageAutoGrow`, the code ensures that unsupported configurations (like enabling `storageAutoGrow `with the `Burstable `tier) are automatically adjusted to avoid errors.
**Smooth Functionality:** When a different tier is selected, the code allows storageAutoGrow to be enabled and configures high availability settings appropriately, ensuring smooth operation without manual intervention.
**Behind-the-Scenes Operation:** The use of conditional expressions and mappings allows the module to automatically adjust settings based on the selected parameters, providing a self-healing mechanism that operates transparently to the user.

This approach ensures that the MySQL server configuration is always valid and optimized for the selected tier and high availability settings, preventing errors and maintaining smooth functionality.

### (Optional) Correlation Id

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.